aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--javassist.jarbin782676 -> 782730 bytes
-rw-r--r--src/main/javassist/bytecode/ConstPool.java3
-rw-r--r--src/test/javassist/JvstTest5.java14
3 files changed, 17 insertions, 0 deletions
diff --git a/javassist.jar b/javassist.jar
index bcdd5600..fcead50d 100644
--- a/javassist.jar
+++ b/javassist.jar
Binary files differ
diff --git a/src/main/javassist/bytecode/ConstPool.java b/src/main/javassist/bytecode/ConstPool.java
index 1ce26b3e..b5113e42 100644
--- a/src/main/javassist/bytecode/ConstPool.java
+++ b/src/main/javassist/bytecode/ConstPool.java
@@ -1433,6 +1433,9 @@ public final class ConstPool
*/
public void write(DataOutputStream out) throws IOException
{
+ if (numOfItems < 0 || Short.MAX_VALUE < numOfItems)
+ throw new IOException("too many constant pool items " + numOfItems);
+
out.writeShort(numOfItems);
LongVector v = items;
int size = numOfItems;
diff --git a/src/test/javassist/JvstTest5.java b/src/test/javassist/JvstTest5.java
index ade41e8c..39af16b9 100644
--- a/src/test/javassist/JvstTest5.java
+++ b/src/test/javassist/JvstTest5.java
@@ -15,6 +15,7 @@ import javassist.expr.ExprEditor;
import javassist.expr.Handler;
import javassist.expr.MethodCall;
import javassist.expr.NewExpr;
+import junit.framework.Assert;
@SuppressWarnings({"rawtypes","unchecked","unused"})
public class JvstTest5 extends JvstTestRoot {
@@ -574,4 +575,17 @@ public class JvstTest5 extends JvstTestRoot {
Object obj = make(cc.getName());
assertEquals(1, invoke(obj, "run"));
}
+
+ public void testTooManyConstPoolItems() throws Exception {
+ CtClass cc = sloader.makeClass("TooManyConstPoolItems");
+ ClassFile cf = cc.getClassFile();
+ ConstPool cPool = cf.getConstPool();
+ for (int i = 0; i <= 65527; i++)
+ cPool.addIntegerInfo(i);
+ try {
+ cc.writeFile();
+ fail("too many items were accepted");
+ }
+ catch (CannotCompileException e) {}
+ }
}