Thread: [Fb-contrib-commit] SF.net SVN: fb-contrib: [689] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-11-19 04:33:47
|
Revision: 689 http://svn.sourceforge.net/fb-contrib/?rev=689&view=rev Author: dbrosius Date: 2006-11-18 20:33:43 -0800 (Sat, 18 Nov 2006) Log Message: ----------- comment out sb Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2006-11-19 03:58:19 UTC (rev 688) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2006-11-19 04:33:43 UTC (rev 689) @@ -115,10 +115,10 @@ String signature = getSigConstantOperand(); if ("(I)V".equals(signature)) { if (lastOpcode == BIPUSH) { - bugReporter.reportBug(new BugInstance(this, "SPP_NO_CHAR_SB_CTOR", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + //bugReporter.reportBug(new BugInstance(this, "SPP_NO_CHAR_SB_CTOR", NORMAL_PRIORITY) + // .addClass(this) + // .addMethod(this) + // .addSourceLine(this)); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-10-13 04:49:03
|
Revision: 936 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=936&view=rev Author: dbrosius Date: 2007-10-12 21:49:06 -0700 (Fri, 12 Oct 2007) Log Message: ----------- guard against a non initialized lastPCs array Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-10-13 03:30:42 UTC (rev 935) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-10-13 04:49:06 UTC (rev 936) @@ -92,7 +92,8 @@ if (seen == ICONST_0) { byte[] bytes = getCode().getCode(); - if (((0x00FF & bytes[lastPCs[3]]) == GOTO) + if ((lastPCs[3] != -1) + && ((0x00FF & bytes[lastPCs[3]]) == GOTO) && ((0x00FF & bytes[lastPCs[2]]) == ICONST_1) && ((0x00FF & bytes[lastPCs[1]]) == IFEQ)) { bugReporter.reportBug(new BugInstance(this, "SPP_USELESS_TRINARY", NORMAL_PRIORITY) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-10-18 03:44:58
|
Revision: 939 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=939&view=rev Author: dbrosius Date: 2007-10-17 20:44:58 -0700 (Wed, 17 Oct 2007) Log Message: ----------- try to salvage SPP_USELESS_TRINARY Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-10-13 06:06:58 UTC (rev 938) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-10-18 03:44:58 UTC (rev 939) @@ -111,25 +111,28 @@ } - if (seen == ICONST_0) { + if (seen == IRETURN) { byte[] bytes = getCode().getCode(); if ((lastPCs[3] != -1) - && ((0x00FF & bytes[lastPCs[3]]) == GOTO) - && ((0x00FF & bytes[lastPCs[2]]) == ICONST_1) - && ((0x00FF & bytes[lastPCs[1]]) == IFEQ)) { - boolean bug = true; - Set<Integer> branchInsSet = branchTargets.get(Integer.valueOf(getPC())); - if (branchInsSet.size() > 1) - bug = false; - branchInsSet = branchTargets.get(Integer.valueOf(lastPCs[2])); - if (branchInsSet != null) - bug = false; - - if (bug) { - bugReporter.reportBug(new BugInstance(this, "SPP_USELESS_TRINARY", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + && ((0x00FF & bytes[lastPCs[3]]) == ICONST_0) + && ((0x00FF & bytes[lastPCs[2]]) == GOTO) + && ((0x00FF & bytes[lastPCs[1]]) == ICONST_1) + && ((0x00FF & bytes[lastPCs[0]]) == IFEQ)) { + if (getMethod().getSignature().endsWith("Z")) { + boolean bug = true; + Set<Integer> branchInsSet = branchTargets.get(Integer.valueOf(lastPCs[1])); + if (branchInsSet != null) + bug = false; + branchInsSet = branchTargets.get(Integer.valueOf(lastPCs[3])); + if ((branchInsSet != null) && branchInsSet.size() > 1) + bug = false; + + if (bug) { + bugReporter.reportBug(new BugInstance(this, "SPP_USELESS_TRINARY", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } } } } else if (seen == LDC2_W) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-10-18 05:37:12
|
Revision: 940 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=940&view=rev Author: dbrosius Date: 2007-10-17 22:37:16 -0700 (Wed, 17 Oct 2007) Log Message: ----------- record IFNULL and IFNONNULL branch targets Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-10-18 03:44:58 UTC (rev 939) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-10-18 05:37:16 UTC (rev 940) @@ -99,7 +99,7 @@ try { stack.mergeJumps(this); - if ((seen >= IFEQ) && (seen <= GOTO)) { + if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == IFNULL) || (seen == IFNONNULL) || (seen == GOTO_W)) { Integer branchTarget = Integer.valueOf(getBranchTarget()); Set<Integer> branchInsSet = branchTargets.get(branchTarget); if (branchInsSet == null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-10-18 05:38:43
|
Revision: 941 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=941&view=rev Author: dbrosius Date: 2007-10-17 22:38:45 -0700 (Wed, 17 Oct 2007) Log Message: ----------- make sure lastPCs[0] is initialized Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-10-18 05:37:16 UTC (rev 940) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-10-18 05:38:45 UTC (rev 941) @@ -113,7 +113,7 @@ if (seen == IRETURN) { byte[] bytes = getCode().getCode(); - if ((lastPCs[3] != -1) + if ((lastPCs[0] != -1) && ((0x00FF & bytes[lastPCs[3]]) == ICONST_0) && ((0x00FF & bytes[lastPCs[2]]) == GOTO) && ((0x00FF & bytes[lastPCs[1]]) == ICONST_1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-11-07 07:01:22
|
Revision: 955 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=955&view=rev Author: dbrosius Date: 2007-11-06 23:01:26 -0800 (Tue, 06 Nov 2007) Log Message: ----------- get rid of java 5 dependencies Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-11-03 04:27:00 UTC (rev 954) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-11-07 07:01:26 UTC (rev 955) @@ -29,6 +29,7 @@ import org.apache.bcel.classfile.ConstantDouble; import org.apache.bcel.classfile.JavaClass; +import com.mebigfatguy.fbcontrib.utils.Integer14; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; import edu.umd.cs.findbugs.BugInstance; @@ -102,14 +103,14 @@ stack.mergeJumps(this); if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == IFNULL) || (seen == IFNONNULL) || (seen == GOTO_W)) { - Integer branchTarget = Integer.valueOf(getBranchTarget()); + Integer branchTarget = Integer14.valueOf(getBranchTarget()); Set<Integer> branchInsSet = branchTargets.get(branchTarget); if (branchInsSet == null) { branchInsSet = new HashSet<Integer>(); branchTargets.put(branchTarget, branchInsSet); } - branchInsSet.add(Integer.valueOf(getPC())); + branchInsSet.add(Integer14.valueOf(getPC())); } if (seen == IFEQ) { @@ -126,10 +127,10 @@ && ((0x00FF & bytes[lastPCs[0]]) == IFEQ)) { if (getMethod().getSignature().endsWith("Z")) { boolean bug = true; - Set<Integer> branchInsSet = branchTargets.get(Integer.valueOf(lastPCs[1])); + Set<Integer> branchInsSet = branchTargets.get(Integer14.valueOf(lastPCs[1])); if (branchInsSet != null) bug = false; - branchInsSet = branchTargets.get(Integer.valueOf(lastPCs[3])); + branchInsSet = branchTargets.get(Integer14.valueOf(lastPCs[3])); if ((branchInsSet != null) && branchInsSet.size() > 1) bug = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-11-10 00:52:18
|
Revision: 965 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=965&view=rev Author: dbrosius Date: 2007-11-09 16:52:21 -0800 (Fri, 09 Nov 2007) Log Message: ----------- handle negative branches Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-11-10 00:37:31 UTC (rev 964) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-11-10 00:52:21 UTC (rev 965) @@ -124,18 +124,18 @@ if ((seen == IFEQ) || (seen == IFLE) || (seen == IFNE)) { if (lastLoadWasString && (lastPCs[0] != -1)) { byte[] bytes = getCode().getCode(); - int loadIns = get1Byte(bytes, lastPCs[2]); + int loadIns = getbyte(bytes, lastPCs[2]); int brOffset = (loadIns == ALOAD) ? 11 : 10; if ((((loadIns >= ALOAD_0) && (loadIns <= ALOAD_3)) || (loadIns == ALOAD)) - && (get1Byte(bytes, lastPCs[3]) == INVOKEVIRTUAL) - && (get1Byte(bytes, lastPCs[2]) == loadIns) - && (get1Byte(bytes, lastPCs[1]) == IFNULL) - && (get1Byte(bytes, lastPCs[0]) == loadIns) - && ((loadIns != ALOAD) || (get1Byte(bytes, lastPCs[2]+1) == get1Byte(bytes, lastPCs[0]+1))) - && ((seen == IFNE) ? get2Bytes(bytes, lastPCs[1]+1) > brOffset : get2Bytes(bytes, lastPCs[1]+1) == brOffset)) { + && (getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) + && (getbyte(bytes, lastPCs[2]) == loadIns) + && (getbyte(bytes, lastPCs[1]) == IFNULL) + && (getbyte(bytes, lastPCs[0]) == loadIns) + && ((loadIns != ALOAD) || (getbyte(bytes, lastPCs[2]+1) == getbyte(bytes, lastPCs[0]+1))) + && ((seen == IFNE) ? getshort(bytes, lastPCs[1]+1) > brOffset : getshort(bytes, lastPCs[1]+1) == brOffset)) { ConstantPool pool = getConstantPool(); - int mpoolIndex = get2Bytes(bytes, lastPCs[3]+1); + int mpoolIndex = getshort(bytes, lastPCs[3]+1); ConstantMethodref cmr = (ConstantMethodref)pool.getConstant(mpoolIndex); int nandtIndex = cmr.getNameAndTypeIndex(); ConstantNameAndType cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); @@ -406,13 +406,14 @@ } } - private int get1Byte(byte[] bytes, int offset) + private int getbyte(byte[] bytes, int offset) { return (0x00FF & bytes[offset]); } - private int get2Bytes(byte[] bytes, int offset) + private int getshort(byte[] bytes, int offset) { - return (0x0000FFFF & (bytes[offset] << 8)) | (0x00FF & bytes[offset+1]); + short s = (short)((0x0000FFFF & (bytes[offset] << 8)) | (0x00FF & bytes[offset+1])); + return s; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-11-24 15:59:00
|
Revision: 981 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=981&view=rev Author: dbrosius Date: 2007-11-24 07:59:04 -0800 (Sat, 24 Nov 2007) Log Message: ----------- USBR fixes Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-11-24 15:55:47 UTC (rev 980) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-11-24 15:59:04 UTC (rev 981) @@ -475,7 +475,6 @@ private int getshort(byte[] bytes, int offset) { - short s = (short)((0x0000FFFF & (bytes[offset] << 8)) | (0x00FF & bytes[offset+1])); - return s; + return (short)((0x0000FFFF & (bytes[offset] << 8)) | (0x00FF & bytes[offset+1])); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-13 21:42:41
|
Revision: 1050 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1050&view=rev Author: dbrosius Date: 2008-06-13 14:42:48 -0700 (Fri, 13 Jun 2008) Log Message: ----------- look for GregorianCalendar Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-06-13 19:07:03 UTC (rev 1049) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-06-13 21:42:48 UTC (rev 1050) @@ -404,7 +404,7 @@ } } } - } else if ("java/util/Calendar".equals(className) + } else if ("java/util/GregorianCalendar".equals(className) && ("after".equals(methodName) || "before".equals(methodName))) { if (stack.getStackDepth() > 1) { OpcodeStack.Item item = stack.getStackItem(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-18 22:51:38
|
Revision: 1053 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1053&view=rev Author: dbrosius Date: 2008-06-18 15:51:46 -0700 (Wed, 18 Jun 2008) Log Message: ----------- fix before/after with GregorianCalendar Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-06-14 20:57:44 UTC (rev 1052) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-06-18 22:51:46 UTC (rev 1053) @@ -408,7 +408,7 @@ && ("after".equals(methodName) || "before".equals(methodName))) { if (stack.getStackDepth() > 1) { OpcodeStack.Item item = stack.getStackItem(0); - if (!"Ljava/util/Calendar;".equals(item.getSignature())) { + if (!"Ljava/util/Calendar;".equals(item.getSignature()) && !"Ljava/util/GregorianCalendar;".equals(item.getSignature())) { bugReporter.reportBug(new BugInstance(this, "SPP_INVALID_CALENDAR_COMPARE", NORMAL_PRIORITY) .addClass(this) .addMethod(this) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-01-17 22:49:04
|
Revision: 986 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=986&view=rev Author: dbrosius Date: 2008-01-17 14:48:05 -0800 (Thu, 17 Jan 2008) Log Message: ----------- guard against empty stack Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-01-11 06:22:19 UTC (rev 985) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-01-17 22:48:05 UTC (rev 986) @@ -429,14 +429,16 @@ } } } else if ("(Ljava/lang/String;)V".equals(signature)) { - OpcodeStack.Item item = stack.getStackItem(0); - String con = (String)item.getConstant(); - if ("".equals(con)) { - bugReporter.reportBug(new BugInstance(this, "SPP_STRINGBUFFER_WITH_EMPTY_STRING", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + String con = (String)item.getConstant(); + if ("".equals(con)) { + bugReporter.reportBug(new BugInstance(this, "SPP_STRINGBUFFER_WITH_EMPTY_STRING", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } } } } else if ("java/math/BigDecimal".equals(className)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-05-26 23:01:28
|
Revision: 1021 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1021&view=rev Author: dbrosius Date: 2008-05-26 16:01:37 -0700 (Mon, 26 May 2008) Log Message: ----------- guard against a null and length() == 0 having a body of continue. ie. don't report Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-05-21 10:45:22 UTC (rev 1020) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-05-26 23:01:37 UTC (rev 1021) @@ -136,16 +136,19 @@ && (getbyte(bytes, lastPCs[0]) == loadIns) && ((loadIns != ALOAD) || (getbyte(bytes, lastPCs[2]+1) == getbyte(bytes, lastPCs[0]+1))) && ((seen == IFNE) ? getshort(bytes, lastPCs[1]+1) > brOffset : getshort(bytes, lastPCs[1]+1) == brOffset)) { - ConstantPool pool = getConstantPool(); - int mpoolIndex = getshort(bytes, lastPCs[3]+1); - ConstantMethodref cmr = (ConstantMethodref)pool.getConstant(mpoolIndex); - int nandtIndex = cmr.getNameAndTypeIndex(); - ConstantNameAndType cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); - if ("length".equals(cnt.getName(pool))) { - bugReporter.reportBug(new BugInstance(this, "SPP_SUSPECT_STRING_TEST", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + int nextOp = getbyte(bytes, getNextPC()); + if ((nextOp != GOTO) && (nextOp != GOTO_W)) { + ConstantPool pool = getConstantPool(); + int mpoolIndex = getshort(bytes, lastPCs[3]+1); + ConstantMethodref cmr = (ConstantMethodref)pool.getConstant(mpoolIndex); + int nandtIndex = cmr.getNameAndTypeIndex(); + ConstantNameAndType cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); + if ("length".equals(cnt.getName(pool))) { + bugReporter.reportBug(new BugInstance(this, "SPP_SUSPECT_STRING_TEST", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-13 21:47:07
|
Revision: 1051 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1051&view=rev Author: dbrosius Date: 2008-06-13 14:47:01 -0700 (Fri, 13 Jun 2008) Log Message: ----------- check GregorianCalendar and Calendar just to be safe Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-06-13 21:42:48 UTC (rev 1050) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-06-13 21:47:01 UTC (rev 1051) @@ -404,7 +404,7 @@ } } } - } else if ("java/util/GregorianCalendar".equals(className) + } else if (("java/util/GregorianCalendar".equals(className) || "java/util/Calendar".equals(className)) && ("after".equals(methodName) || "before".equals(methodName))) { if (stack.getStackDepth() > 1) { OpcodeStack.Item item = stack.getStackItem(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-07-11 03:40:33
|
Revision: 1059 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1059&view=rev Author: dbrosius Date: 2008-07-10 20:40:42 -0700 (Thu, 10 Jul 2008) Log Message: ----------- use the moved getbyte and getshort methods in CodeByteUtils Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-07-11 03:38:43 UTC (rev 1058) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-07-11 03:40:42 UTC (rev 1059) @@ -36,6 +36,7 @@ import org.apache.bcel.classfile.LocalVariable; import org.apache.bcel.classfile.LocalVariableTable; +import com.mebigfatguy.fbcontrib.utils.CodeByteUtils; import com.mebigfatguy.fbcontrib.utils.Integer14; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; @@ -126,20 +127,20 @@ if ((seen == IFEQ) || (seen == IFLE) || (seen == IFNE)) { if (lastLoadWasString && (lastPCs[0] != -1)) { byte[] bytes = getCode().getCode(); - int loadIns = getbyte(bytes, lastPCs[2]); + int loadIns = CodeByteUtils.getbyte(bytes, lastPCs[2]); int brOffset = (loadIns == ALOAD) ? 11 : 10; if ((((loadIns >= ALOAD_0) && (loadIns <= ALOAD_3)) || (loadIns == ALOAD)) - && (getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) - && (getbyte(bytes, lastPCs[2]) == loadIns) - && (getbyte(bytes, lastPCs[1]) == IFNULL) - && (getbyte(bytes, lastPCs[0]) == loadIns) - && ((loadIns != ALOAD) || (getbyte(bytes, lastPCs[2]+1) == getbyte(bytes, lastPCs[0]+1))) - && ((seen == IFNE) ? getshort(bytes, lastPCs[1]+1) > brOffset : getshort(bytes, lastPCs[1]+1) == brOffset)) { - int nextOp = getbyte(bytes, getNextPC()); + && (CodeByteUtils.getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) + && (CodeByteUtils.getbyte(bytes, lastPCs[2]) == loadIns) + && (CodeByteUtils.getbyte(bytes, lastPCs[1]) == IFNULL) + && (CodeByteUtils.getbyte(bytes, lastPCs[0]) == loadIns) + && ((loadIns != ALOAD) || (CodeByteUtils.getbyte(bytes, lastPCs[2]+1) == CodeByteUtils.getbyte(bytes, lastPCs[0]+1))) + && ((seen == IFNE) ? CodeByteUtils.getshort(bytes, lastPCs[1]+1) > brOffset : CodeByteUtils.getshort(bytes, lastPCs[1]+1) == brOffset)) { + int nextOp = CodeByteUtils.getbyte(bytes, getNextPC()); if ((nextOp != GOTO) && (nextOp != GOTO_W)) { ConstantPool pool = getConstantPool(); - int mpoolIndex = getshort(bytes, lastPCs[3]+1); + int mpoolIndex = CodeByteUtils.getshort(bytes, lastPCs[3]+1); ConstantMethodref cmr = (ConstantMethodref)pool.getConstant(mpoolIndex); int nandtIndex = cmr.getNameAndTypeIndex(); ConstantNameAndType cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); @@ -157,17 +158,17 @@ if (seen == IFNE) { byte[] bytes = getCode().getCode(); if (lastPCs[2] != -1) { - if ((getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) - && (getbyte(bytes, lastPCs[2]) == INVOKEVIRTUAL)) { + if ((CodeByteUtils.getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) + && (CodeByteUtils.getbyte(bytes, lastPCs[2]) == INVOKEVIRTUAL)) { ConstantPool pool = getConstantPool(); - int toStringIndex = getshort(bytes, lastPCs[2]+1); + int toStringIndex = CodeByteUtils.getshort(bytes, lastPCs[2]+1); ConstantMethodref toStringMR = (ConstantMethodref)pool.getConstant(toStringIndex); String toStringCls = toStringMR.getClass(pool); if (toStringCls.startsWith("java.lang.StringBu")) { int nandtIndex = toStringMR.getNameAndTypeIndex(); ConstantNameAndType cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); if ("toString".equals(cnt.getName(pool))) { - int lengthIndex = getshort(bytes, lastPCs[3]+1); + int lengthIndex = CodeByteUtils.getshort(bytes, lastPCs[3]+1); ConstantMethodref lengthMR = (ConstantMethodref)pool.getConstant(lengthIndex); nandtIndex = lengthMR.getNameAndTypeIndex(); cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); @@ -189,23 +190,23 @@ byte[] bytes = getCode().getCode(); if (lastPCs[1] != -1) { - int loadIns = getbyte(bytes, lastPCs[2]); - if ((getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) + int loadIns = CodeByteUtils.getbyte(bytes, lastPCs[2]); + if ((CodeByteUtils.getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) && ((loadIns == LDC) || (loadIns == LDC_W)) - && (getbyte(bytes, lastPCs[1]) == INVOKEVIRTUAL)) { + && (CodeByteUtils.getbyte(bytes, lastPCs[1]) == INVOKEVIRTUAL)) { ConstantPool pool = getConstantPool(); - int toStringIndex = getshort(bytes, lastPCs[1]+1); + int toStringIndex = CodeByteUtils.getshort(bytes, lastPCs[1]+1); ConstantMethodref toStringMR = (ConstantMethodref)pool.getConstant(toStringIndex); String toStringCls = toStringMR.getClass(pool); if (toStringCls.startsWith("java.lang.StringBu")) { - int consIndex = getbyte(bytes, lastPCs[2]+1); + int consIndex = CodeByteUtils.getbyte(bytes, lastPCs[2]+1); Constant c = pool.getConstant(consIndex); if (c instanceof ConstantString) { if ("".equals(((ConstantString) c).getBytes(pool))) { int nandtIndex = toStringMR.getNameAndTypeIndex(); ConstantNameAndType cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); if ("toString".equals(cnt.getName(pool))) { - int lengthIndex = getshort(bytes, lastPCs[3]+1); + int lengthIndex = CodeByteUtils.getshort(bytes, lastPCs[3]+1); ConstantMethodref lengthMR = (ConstantMethodref)pool.getConstant(lengthIndex); nandtIndex = lengthMR.getNameAndTypeIndex(); cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); @@ -505,14 +506,4 @@ lastPCs[3] = getPC(); } } - - private int getbyte(byte[] bytes, int offset) - { - return (0x00FF & bytes[offset]); - } - - private int getshort(byte[] bytes, int offset) - { - return (short)((0x0000FFFF & (bytes[offset] << 8)) | (0x00FF & bytes[offset+1])); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-07-11 04:00:48
|
Revision: 1061 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1061&view=rev Author: dbrosius Date: 2008-07-10 21:00:57 -0700 (Thu, 10 Jul 2008) Log Message: ----------- patch bug in findbugs proper, with mergeJumps throwing away static typing. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-07-11 03:58:04 UTC (rev 1060) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-07-11 04:00:57 UTC (rev 1061) @@ -409,7 +409,9 @@ && ("after".equals(methodName) || "before".equals(methodName))) { if (stack.getStackDepth() > 1) { OpcodeStack.Item item = stack.getStackItem(0); - if (!"Ljava/util/Calendar;".equals(item.getSignature()) && !"Ljava/util/GregorianCalendar;".equals(item.getSignature())) { + String itemSig = item.getSignature(); + //Rule out java.lang.Object as mergeJumps can throw away type info (BUG) + if (!"Ljava/lang/Object;".equals(itemSig) && !"Ljava/util/Calendar;".equals(itemSig) && !"Ljava/util/GregorianCalendar;".equals(itemSig)) { bugReporter.reportBug(new BugInstance(this, "SPP_INVALID_CALENDAR_COMPARE", NORMAL_PRIORITY) .addClass(this) .addMethod(this) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |