From e0557fe03950eca0fa1f4183fab9bf028df28bf6 Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Sat, 14 Aug 2021 00:08:51 -0600 Subject: [PATCH] Fix reading of short values from constant pool table (#548) --- .../java/io/github/classgraph/Classfile.java | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/main/java/io/github/classgraph/Classfile.java b/src/main/java/io/github/classgraph/Classfile.java index 9efc0dac0..736a3b868 100644 --- a/src/main/java/io/github/classgraph/Classfile.java +++ b/src/main/java/io/github/classgraph/Classfile.java @@ -824,24 +824,6 @@ private boolean constantPoolStringEquals(final int cpIdx, final String asciiStr) // ------------------------------------------------------------------------------------------------------------- - /** - * Read an unsigned short from the constant pool. - * - * @param cpIdx - * the constant pool index. - * @return the unsigned short - * @throws IOException - * If an I/O exception occurred. - */ - private int cpReadUnsignedShort(final int cpIdx) throws IOException { - if (cpIdx < 1 || cpIdx >= cpCount) { - throw new ClassfileFormatException("Constant pool index " + cpIdx + ", should be in range [1, " - + (cpCount - 1) + "] -- cannot continue reading class. " - + "Please report this at https://github.com/classgraph/classgraph/issues"); - } - return reader.readUnsignedShort(entryOffset[cpIdx]); - } - /** * Read an int from the constant pool. * @@ -985,7 +967,7 @@ private Object readAnnotationElementValue() throws IOException { case 'J': return cpReadLong(reader.readUnsignedShort()); case 'S': - return (short) cpReadUnsignedShort(reader.readUnsignedShort()); + return (short) cpReadInt(reader.readUnsignedShort()); case 'Z': return cpReadInt(reader.readUnsignedShort()) != 0; case 's':