Browse Source

prohibits too many items from being added to a constant pool.

the previous commit was wrong.
tags/rel_3_29_1_ga
chibash 1 year ago
parent
commit
3528a20dd9

BIN
javassist.jar View File


+ 1
- 1
src/main/javassist/bytecode/ConstPool.java View File

*/ */
public void write(DataOutputStream out) throws IOException public void write(DataOutputStream out) throws IOException
{ {
if (numOfItems < 0 || Short.MAX_VALUE < numOfItems)
if (numOfItems < 0 || ((1 << 16) - 1) < numOfItems)
throw new IOException("too many constant pool items " + numOfItems); throw new IOException("too many constant pool items " + numOfItems);


out.writeShort(numOfItems); out.writeShort(numOfItems);

+ 7
- 2
src/test/javassist/JvstTest5.java View File

CtClass cc = sloader.makeClass("TooManyConstPoolItems"); CtClass cc = sloader.makeClass("TooManyConstPoolItems");
ClassFile cf = cc.getClassFile(); ClassFile cf = cc.getClassFile();
ConstPool cPool = cf.getConstPool(); ConstPool cPool = cf.getConstPool();
for (int i = 0; i <= 65527; i++)
cPool.addIntegerInfo(i);
int size = cPool.getSize();
while (cPool.getSize() < 65536 - 6)
cPool.addIntegerInfo(cPool.getSize());

cc.writeFile();
cc.defrost();
cPool.addIntegerInfo(-1);
try { try {
cc.writeFile(); cc.writeFile();
fail("too many items were accepted"); fail("too many items were accepted");

Loading…
Cancel
Save