You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2022/11/20 10:17:54 UTC
[commons-bcel] branch master updated: Fix an instance of IAE when it should be ClassFormatException
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git
The following commit(s) were added to refs/heads/master by this push:
new 1a99a1e5 Fix an instance of IAE when it should be ClassFormatException
1a99a1e5 is described below
commit 1a99a1e59e242163169079f16710aa579ed54535
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sun Nov 20 10:17:49 2022 +0000
Fix an instance of IAE when it should be ClassFormatException
Found by OSS-Fuzz
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/bcel/classfile/StackMapType.java | 2 +-
src/test/java/org/apache/bcel/OssFuzzTestCase.java | 5 +++++
src/test/resources/ossfuzz/issue53543/Test.class | Bin 0 -> 57 bytes
4 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index fe0e051c..d1557b31 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -93,6 +93,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.StackMapType.StackMapType(DataInput, ConstantPool) reads signed instead of unsigned shorts from its DataInput.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ConstantInvokeDynamic.ConstantInvokeDynamic(DataInput).</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.util.ClassPath hashCode() and equals() don't match.</action>
+ <action type="fix" dev="markt" due-to="OSS-Fuzz">org.apache.bcel.classfile.StackMapType constructors now throw ClassFormatException on invalid input.</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump spotbugs-maven-plugin from 4.7.2.2 to 4.7.3.0 #167.</action>
<action type="update" dev="ggregory" due-to="Dependabot">Bump jmh.version from 1.35 to 1.36 #170.</action>
diff --git a/src/main/java/org/apache/bcel/classfile/StackMapType.java b/src/main/java/org/apache/bcel/classfile/StackMapType.java
index aff4bcb1..438fa5df 100644
--- a/src/main/java/org/apache/bcel/classfile/StackMapType.java
+++ b/src/main/java/org/apache/bcel/classfile/StackMapType.java
@@ -61,7 +61,7 @@ public final class StackMapType implements Cloneable {
private byte checkType(final byte type) {
if (type < Const.ITEM_Bogus || type > Const.ITEM_NewObject) {
- throw new IllegalArgumentException("Illegal type for StackMapType: " + type);
+ throw new ClassFormatException("Illegal type for StackMapType: " + type);
}
return type;
}
diff --git a/src/test/java/org/apache/bcel/OssFuzzTestCase.java b/src/test/java/org/apache/bcel/OssFuzzTestCase.java
index dacf64f6..9f4e63bb 100644
--- a/src/test/java/org/apache/bcel/OssFuzzTestCase.java
+++ b/src/test/java/org/apache/bcel/OssFuzzTestCase.java
@@ -42,6 +42,11 @@ public class OssFuzzTestCase {
testOssFuzzReproducer("52168");
}
+ @Test
+ public void testIssue53543() throws Exception {
+ testOssFuzzReproducer("53543");
+ }
+
private void testOssFuzzReproducer(final String issue) throws Exception {
final File reproducerFile = new File("target/test-classes/ossfuzz/issue" + issue + "/Test.class");
try (final FileInputStream reproducerInputStream = new FileInputStream(reproducerFile)) {
diff --git a/src/test/resources/ossfuzz/issue53543/Test.class b/src/test/resources/ossfuzz/issue53543/Test.class
new file mode 100644
index 00000000..808e3379
Binary files /dev/null and b/src/test/resources/ossfuzz/issue53543/Test.class differ