You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/11/22 12:52:34 UTC

[commons-bcel] branch master updated (7b5ac741 -> e8c4bfbe)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git


    from 7b5ac741 When parsing, limit arrays to 255 dimensions as per JVM specification
     new 24547cf7 org.apache.bcel.classfile.LocalVariableTable constructors now throw ClassFormatException on invalid input
     new b00e5e27 org.apache.bcel.classfile.LocalVariableTypeTable constructors now throw ClassFormatException on invalid input
     new 57d1a3c6 org.apache.bcel.classfile.ModuleMainClass constructors now throw ClassFormatException on invalid input
     new cc9c33cb org.apache.bcel.classfile.ModulePackages constructors now throw ClassFormatException on invalid input
     new 6495de33 org.apache.bcel.classfile.NestHost constructors now throw ClassFormatException on invalid input
     new d7f558d9 org.apache.bcel.classfile.NestMembers constructors now throw ClassFormatException on invalid input
     new 21fc4ab6 Sort fixes
     new 939f0eba org.apache.bcel.classfile.StackMap constructors now throw ClassFormatException on invalid input
     new d1f5fd2d org.apache.bcel.classfile.StackMap constructors now throw ClassFormatException on invalid input
     new f9e50479 org.apache.bcel.classfile.Signature constructors now throw ClassFormatException on invalid input
     new e8c4bfbe Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-bcel.git

The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                            | 47 +++++++++++++---------
 .../org/apache/bcel/classfile/LocalVariable.java   |  2 +
 .../apache/bcel/classfile/LocalVariableTable.java  |  4 +-
 .../bcel/classfile/LocalVariableTypeTable.java     |  6 ++-
 .../org/apache/bcel/classfile/ModuleMainClass.java |  3 +-
 .../org/apache/bcel/classfile/ModulePackages.java  |  2 +
 .../java/org/apache/bcel/classfile/NestHost.java   |  3 +-
 .../org/apache/bcel/classfile/NestMembers.java     |  6 ++-
 .../java/org/apache/bcel/classfile/Signature.java  |  3 ++
 .../java/org/apache/bcel/classfile/StackMap.java   | 10 +++--
 .../org/apache/bcel/classfile/StackMapEntry.java   | 17 ++++----
 .../org/apache/bcel/classfile/StackMapType.java    |  2 +
 12 files changed, 64 insertions(+), 41 deletions(-)


[commons-bcel] 11/11: Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-bcel.git

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit e8c4bfbe0a00dc2c6b7d639c3880ca0d7faafbe4
Merge: f9e50479 7b5ac741
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Tue Nov 22 07:52:29 2022 -0500

    Merge branch 'master' of
    https://gitbox.apache.org/repos/asf/commons-bcel.git

 src/changes/changes.xml                                |   2 ++
 .../java/org/apache/bcel/classfile/ElementValue.java   |  12 +++++++++++-
 src/test/java/org/apache/bcel/OssFuzzTestCase.java     |   5 +++++
 src/test/resources/ossfuzz/issue53620/Test.class       | Bin 0 -> 227530 bytes
 4 files changed, 18 insertions(+), 1 deletion(-)

diff --cc src/changes/changes.xml
index 6825dc62,ecd81f27..8bed5637
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@@ -75,42 -75,37 +75,44 @@@ The <action> type attribute can be add,
        <action                  type="add" dev="ggregory" due-to="nbauma109, Gary Gregory">Add org.apache.bcel.classfile.JavaClass.getSourceFilePath().</action>
        <action                  type="add" dev="ggregory" due-to="nbauma109, Gary Gregory">Add org.apache.bcel.generic.PUSH.PUSH(ConstantPoolGen, ArrayType).</action>
        <!-- FIX -->
 -      <action                  type="fix" dev="ggregory" due-to="nbauma109, Gary Gregory">Typo in SimpleElementValue error message #161.</action>
 -      <action                  type="fix" dev="ggregory" due-to="Mark Roberts, Gary Gregory">Fix code duplication in org.apache.bcel.verifier.structurals.ExceptionHandlers.ExceptionHandlers(MethodGen).</action>
 -      <action                  type="fix" dev="ggregory" due-to="Sam Ng, Gary Gregory">Improve test coverage to bcel/generic and UtilityTest #162.</action>
 -      <action                  type="fix" dev="ggregory" due-to="nbauma109, Gary Gregory">Code coverage and unit tests on the verifier #166.</action>
 -      <action                  type="fix" dev="markt" due-to="OSS-Fuzz">References to constant pool entries that are not of the expected type should throw ClassFormatException, not ClassCastException.</action>
 -      <action                  type="fix" dev="markt" due-to="OSS-Fuzz">When parsing an invalid class, ensure ClassParser.parse() throws ClassFormatException, not IllegalArgumentException.</action>
 -      <action                  type="fix" dev="markt" due-to="OSS-Fuzz">org.apache.bcel.classfile.Code constructors now throw ClassFormatException on invalid input.</action>
 -      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Deprecated constructors now throw ClassFormatException on invalid length input.</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">Avoid internal NPE in org.apache.bcel.util.ClassPath.getInputStream(String, String).</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">InstructionConstants.ALOAD_0 value is wrong (regression from 6.6.0).</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">InstructionConstants.DCONST_0 value is wrong (regression from 6.6.0).</action>
        <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Attribute constructors now throw ClassFormatException on invalid name index input.</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.CodeException constructors now throw ClassFormatException on invalid input.</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.classfile.ConstantValue constructors now throw ClassFormatException on invalid length input.</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Deprecated constructors now throw ClassFormatException on invalid length input.</action>
        <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.EnclosingMethod constructors now throw ClassFormatException on invalid length, class index, or method index input.</action>
 -      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Synthetic constructors now throw ClassFormatException on invalid length input.</action>
 -      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Signature constructors now throw ClassFormatException on invalid length input.</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ExceptionTable constructors now throw ClassFormatException on invalid input.</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.InnerClasses constructors now throw ClassFormatException on invalid input.</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LineNumber constructors now throw ClassFormatException on invalid input.</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariable constructors now throw ClassFormatException on invalid input.</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariableTable constructors now throw ClassFormatException on invalid input.</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariableTypeTable constructors now throw ClassFormatException on invalid input.</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ModuleMainClass constructors now throw ClassFormatException on invalid input.</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ModulePackages constructors now throw ClassFormatException on invalid input.</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.NestHost constructors now throw ClassFormatException on invalid input.</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.NestMembers constructors now throw ClassFormatException on invalid input.</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Signature constructors now throw ClassFormatException on invalid input.</action>
        <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.SourceFile constructors now throw ClassFormatException on invalid input.</action>
 -      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">InstructionConstants.ALOAD_0 value is wrong (regression from 6.6.0).</action>
 -      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">InstructionConstants.DCONST_0 value is wrong (regression from 6.6.0).</action>
 -      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">Avoid internal NPE in org.apache.bcel.util.ClassPath.getInputStream(String, String).</action>
 +      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.StackMap constructors now throw ClassFormatException on invalid input.</action>
        <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.StackMapEntry.StackMapEntry(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.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.classfile.Synthetic constructors now throw ClassFormatException on invalid length input.</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>
 +      <action                  type="fix" dev="ggregory" due-to="Mark Roberts, Gary Gregory">Fix code duplication in org.apache.bcel.verifier.structurals.ExceptionHandlers.ExceptionHandlers(MethodGen).</action>
 +      <action                  type="fix" dev="ggregory" due-to="Sam Ng, Gary Gregory">Improve test coverage to bcel/generic and UtilityTest #162.</action>
        <action                  type="fix" dev="ggregory" due-to="nbauma109, Gary Gregory">Code coverage and bug fixes for bcelifier #171.</action>
 +      <action                  type="fix" dev="ggregory" due-to="nbauma109, Gary Gregory">Code coverage and unit tests on the verifier #166.</action>
 +      <action                  type="fix" dev="ggregory" due-to="nbauma109, Gary Gregory">Typo in SimpleElementValue error message #161.</action>
        <action                  type="fix" dev="markt" due-to="Mark Thomas, Gary Gregory">org.apache.bcel.classfile.Attribute constructors now throw ClassFormatException on invalid length input.</action>
 -      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.CodeException constructors now throw ClassFormatException on invalid input.</action>
 -      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ExceptionTable constructors now throw ClassFormatException on invalid input.</action>
 -      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.InnerClasses constructors now throw ClassFormatException on invalid input.</action>
 -      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LineNumber constructors now throw ClassFormatException on invalid input.</action>
 -      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariable constructors now throw ClassFormatException on invalid input.</action>
 +      <action                  type="fix" dev="markt" due-to="OSS-Fuzz">References to constant pool entries that are not of the expected type should throw ClassFormatException, not ClassCastException.</action>
 +      <action                  type="fix" dev="markt" due-to="OSS-Fuzz">When parsing an invalid class, ensure ClassParser.parse() throws ClassFormatException, not IllegalArgumentException.</action>
 +      <action                  type="fix" dev="markt" due-to="OSS-Fuzz">org.apache.bcel.classfile.Code constructors now throw ClassFormatException on invalid input.</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="fix" dev="markt" due-to="OSS-Fuzz">When parsing class files, limit arrays to no more than 255 dimensions as per section 4.4.1 of the JVM specification</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>
      </release>


[commons-bcel] 09/11: org.apache.bcel.classfile.StackMap constructors now throw ClassFormatException on invalid input

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit d1f5fd2d3c34e1e8b460b6d74bedc5b2c30c9fae
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Tue Nov 22 07:46:06 2022 -0500

    org.apache.bcel.classfile.StackMap constructors now throw
    ClassFormatException on invalid input
---
 src/changes/changes.xml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 943c779b..2fc6901c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -96,6 +96,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.NestMembers constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Signature constructors now throw ClassFormatException on invalid length input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.SourceFile constructors now throw ClassFormatException on invalid input.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.StackMap constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.StackMapEntry.StackMapEntry(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.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.Synthetic constructors now throw ClassFormatException on invalid length input.</action>


[commons-bcel] 01/11: org.apache.bcel.classfile.LocalVariableTable constructors now throw ClassFormatException on invalid input

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit 24547cf7ec772185ad04e5dd9aa63bbf9ce2aea5
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Mon Nov 21 16:13:04 2022 -0500

    org.apache.bcel.classfile.LocalVariableTable constructors now throw
    ClassFormatException on invalid input
---
 src/changes/changes.xml                                         | 1 +
 src/main/java/org/apache/bcel/classfile/LocalVariable.java      | 2 ++
 src/main/java/org/apache/bcel/classfile/LocalVariableTable.java | 4 +++-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 25c0b667..238f3320 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -104,6 +104,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.InnerClasses constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LineNumber constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariable constructors now throw ClassFormatException on invalid input.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariableTable 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/LocalVariable.java b/src/main/java/org/apache/bcel/classfile/LocalVariable.java
index a67daf51..0b27b693 100644
--- a/src/main/java/org/apache/bcel/classfile/LocalVariable.java
+++ b/src/main/java/org/apache/bcel/classfile/LocalVariable.java
@@ -37,6 +37,8 @@ import org.apache.bcel.util.Args;
  */
 public final class LocalVariable implements Cloneable, Node, Constants {
 
+    static final LocalVariable[] EMPTY_ARRAY = {};
+
     /** Range in which the variable is valid. */
     private int startPc;
 
diff --git a/src/main/java/org/apache/bcel/classfile/LocalVariableTable.java b/src/main/java/org/apache/bcel/classfile/LocalVariableTable.java
index da1c1796..d1125708 100644
--- a/src/main/java/org/apache/bcel/classfile/LocalVariableTable.java
+++ b/src/main/java/org/apache/bcel/classfile/LocalVariableTable.java
@@ -24,6 +24,7 @@ import java.util.Iterator;
 import java.util.stream.Stream;
 
 import org.apache.bcel.Const;
+import org.apache.bcel.util.Args;
 
 /**
  * This class represents colection of local variables in a method. This attribute is contained in the <em>Code</em>
@@ -62,7 +63,8 @@ public class LocalVariableTable extends Attribute implements Iterable<LocalVaria
      */
     public LocalVariableTable(final int nameIndex, final int length, final LocalVariable[] localVariableTable, final ConstantPool constantPool) {
         super(Const.ATTR_LOCAL_VARIABLE_TABLE, nameIndex, length, constantPool);
-        this.localVariableTable = localVariableTable;
+        this.localVariableTable = localVariableTable != null ? localVariableTable : LocalVariable.EMPTY_ARRAY;
+        Args.requireU2(this.localVariableTable.length, "localVariableTable.length");
     }
 
     /**


[commons-bcel] 07/11: Sort fixes

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit 21fc4ab63fd2e84198185ad4a1bf7786ee778fe7
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Tue Nov 22 07:44:25 2022 -0500

    Sort fixes
---
 src/changes/changes.xml | 45 ++++++++++++++++++++++-----------------------
 1 file changed, 22 insertions(+), 23 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f6ca3f00..943c779b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -75,31 +75,15 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="add" dev="ggregory" due-to="nbauma109, Gary Gregory">Add org.apache.bcel.classfile.JavaClass.getSourceFilePath().</action>
       <action                  type="add" dev="ggregory" due-to="nbauma109, Gary Gregory">Add org.apache.bcel.generic.PUSH.PUSH(ConstantPoolGen, ArrayType).</action>
       <!-- FIX -->
-      <action                  type="fix" dev="ggregory" due-to="nbauma109, Gary Gregory">Typo in SimpleElementValue error message #161.</action>
-      <action                  type="fix" dev="ggregory" due-to="Mark Roberts, Gary Gregory">Fix code duplication in org.apache.bcel.verifier.structurals.ExceptionHandlers.ExceptionHandlers(MethodGen).</action>
-      <action                  type="fix" dev="ggregory" due-to="Sam Ng, Gary Gregory">Improve test coverage to bcel/generic and UtilityTest #162.</action>
-      <action                  type="fix" dev="ggregory" due-to="nbauma109, Gary Gregory">Code coverage and unit tests on the verifier #166.</action>
-      <action                  type="fix" dev="markt" due-to="OSS-Fuzz">References to constant pool entries that are not of the expected type should throw ClassFormatException, not ClassCastException.</action>
-      <action                  type="fix" dev="markt" due-to="OSS-Fuzz">When parsing an invalid class, ensure ClassParser.parse() throws ClassFormatException, not IllegalArgumentException.</action>
-      <action                  type="fix" dev="markt" due-to="OSS-Fuzz">org.apache.bcel.classfile.Code constructors now throw ClassFormatException on invalid input.</action>
-      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Deprecated constructors now throw ClassFormatException on invalid length input.</action>
-      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Attribute constructors now throw ClassFormatException on invalid name index input.</action>
-      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ConstantValue constructors now throw ClassFormatException on invalid length input.</action>
-      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.EnclosingMethod constructors now throw ClassFormatException on invalid length, class index, or method index input.</action>
-      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Synthetic constructors now throw ClassFormatException on invalid length input.</action>
-      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Signature constructors now throw ClassFormatException on invalid length input.</action>
-      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.SourceFile constructors now throw ClassFormatException on invalid input.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">Avoid internal NPE in org.apache.bcel.util.ClassPath.getInputStream(String, String).</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">InstructionConstants.ALOAD_0 value is wrong (regression from 6.6.0).</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">InstructionConstants.DCONST_0 value is wrong (regression from 6.6.0).</action>
-      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">Avoid internal NPE in org.apache.bcel.util.ClassPath.getInputStream(String, String).</action>
-      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.StackMapEntry.StackMapEntry(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.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>
-      <action                  type="fix" dev="ggregory" due-to="nbauma109, Gary Gregory">Code coverage and bug fixes for bcelifier #171.</action>
-      <action                  type="fix" dev="markt" due-to="Mark Thomas, Gary Gregory">org.apache.bcel.classfile.Attribute constructors now throw ClassFormatException on invalid length input.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Attribute constructors now throw ClassFormatException on invalid name index input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.CodeException constructors now throw ClassFormatException on invalid input.</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.classfile.ConstantValue constructors now throw ClassFormatException on invalid length input.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Deprecated constructors now throw ClassFormatException on invalid length input.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.EnclosingMethod constructors now throw ClassFormatException on invalid length, class index, or method index input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ExceptionTable constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.InnerClasses constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LineNumber constructors now throw ClassFormatException on invalid input.</action>
@@ -110,7 +94,22 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ModulePackages constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.NestHost constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.NestMembers constructors now throw ClassFormatException on invalid input.</action>
-      <!-- UPDATE -->
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Signature constructors now throw ClassFormatException on invalid length input.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.SourceFile constructors now throw ClassFormatException on invalid input.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.StackMapEntry.StackMapEntry(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.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.Synthetic constructors now throw ClassFormatException on invalid length input.</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="ggregory" due-to="Mark Roberts, Gary Gregory">Fix code duplication in org.apache.bcel.verifier.structurals.ExceptionHandlers.ExceptionHandlers(MethodGen).</action>
+      <action                  type="fix" dev="ggregory" due-to="Sam Ng, Gary Gregory">Improve test coverage to bcel/generic and UtilityTest #162.</action>
+      <action                  type="fix" dev="ggregory" due-to="nbauma109, Gary Gregory">Code coverage and bug fixes for bcelifier #171.</action>
+      <action                  type="fix" dev="ggregory" due-to="nbauma109, Gary Gregory">Code coverage and unit tests on the verifier #166.</action>
+      <action                  type="fix" dev="ggregory" due-to="nbauma109, Gary Gregory">Typo in SimpleElementValue error message #161.</action>
+      <action                  type="fix" dev="markt" due-to="Mark Thomas, Gary Gregory">org.apache.bcel.classfile.Attribute constructors now throw ClassFormatException on invalid length input.</action>
+      <action                  type="fix" dev="markt" due-to="OSS-Fuzz">References to constant pool entries that are not of the expected type should throw ClassFormatException, not ClassCastException.</action>
+      <action                  type="fix" dev="markt" due-to="OSS-Fuzz">When parsing an invalid class, ensure ClassParser.parse() throws ClassFormatException, not IllegalArgumentException.</action>
+      <action                  type="fix" dev="markt" due-to="OSS-Fuzz">org.apache.bcel.classfile.Code constructors now throw ClassFormatException on invalid input.</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>
     </release>


[commons-bcel] 05/11: org.apache.bcel.classfile.NestHost constructors now throw ClassFormatException on invalid input

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit 6495de33a6f5a3fee1c46ec2ffd3af9cef6554cb
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Mon Nov 21 16:31:20 2022 -0500

    org.apache.bcel.classfile.NestHost constructors now throw
    ClassFormatException on invalid input
---
 src/changes/changes.xml                               | 1 +
 src/main/java/org/apache/bcel/classfile/NestHost.java | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 3fb0bf6e..541d5946 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -108,6 +108,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariableTypeTable constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ModuleMainClass constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ModulePackages constructors now throw ClassFormatException on invalid input.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.NestHost 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/NestHost.java b/src/main/java/org/apache/bcel/classfile/NestHost.java
index 9ef0361e..88e41532 100644
--- a/src/main/java/org/apache/bcel/classfile/NestHost.java
+++ b/src/main/java/org/apache/bcel/classfile/NestHost.java
@@ -22,6 +22,7 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 
 import org.apache.bcel.Const;
+import org.apache.bcel.util.Args;
 
 /**
  * This class is derived from <em>Attribute</em> and records the nest host of the nest to which the current class or
@@ -55,7 +56,7 @@ public final class NestHost extends Attribute {
      */
     public NestHost(final int nameIndex, final int length, final int hostClassIndex, final ConstantPool constantPool) {
         super(Const.ATTR_NEST_MEMBERS, nameIndex, length, constantPool);
-        this.hostClassIndex = hostClassIndex;
+        this.hostClassIndex = Args.requireU2(hostClassIndex, "hostClassIndex");
     }
 
     /**


[commons-bcel] 08/11: org.apache.bcel.classfile.StackMap constructors now throw ClassFormatException on invalid input

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit 939f0eba29d3308871adc2948a6ece803c93eece
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Tue Nov 22 07:45:43 2022 -0500

    org.apache.bcel.classfile.StackMap constructors now throw
    ClassFormatException on invalid input
---
 src/main/java/org/apache/bcel/classfile/StackMap.java   | 10 ++++++----
 .../java/org/apache/bcel/classfile/StackMapEntry.java   | 17 +++++++----------
 .../java/org/apache/bcel/classfile/StackMapType.java    |  2 ++
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/main/java/org/apache/bcel/classfile/StackMap.java b/src/main/java/org/apache/bcel/classfile/StackMap.java
index 30f38034..80f2d2a7 100644
--- a/src/main/java/org/apache/bcel/classfile/StackMap.java
+++ b/src/main/java/org/apache/bcel/classfile/StackMap.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.util.Arrays;
 
 import org.apache.bcel.Const;
+import org.apache.bcel.util.Args;
 
 /**
  * This class represents a stack map attribute used for preverification of Java classes for the
@@ -73,9 +74,10 @@ public final class StackMap extends Attribute {
      *
      * @param constantPool Array of constants
      */
-    public StackMap(final int nameIndex, final int length, final StackMapEntry[] map, final ConstantPool constantPool) {
+    public StackMap(final int nameIndex, final int length, final StackMapEntry[] table, final ConstantPool constantPool) {
         super(Const.ATTR_STACK_MAP, nameIndex, length, constantPool);
-        this.table = map;
+        this.table = table != null ? table : StackMapEntry.EMPTY_ARRAY;
+        Args.requireU2(this.table.length, "table.length");
     }
 
     /**
@@ -117,7 +119,7 @@ public final class StackMap extends Attribute {
     }
 
     public int getMapLength() {
-        return table == null ? 0 : table.length;
+        return table.length;
     }
 
     /**
@@ -131,7 +133,7 @@ public final class StackMap extends Attribute {
      * @param table Array of stack map entries
      */
     public void setStackMap(final StackMapEntry[] table) {
-        this.table = table;
+        this.table = table != null ? table : StackMapEntry.EMPTY_ARRAY;
         int len = 2; // Length of 'number_of_entries' field prior to the array of stack maps
         for (final StackMapEntry element : table) {
             len += element.getMapEntrySize();
diff --git a/src/main/java/org/apache/bcel/classfile/StackMapEntry.java b/src/main/java/org/apache/bcel/classfile/StackMapEntry.java
index 9da003db..0eed5838 100644
--- a/src/main/java/org/apache/bcel/classfile/StackMapEntry.java
+++ b/src/main/java/org/apache/bcel/classfile/StackMapEntry.java
@@ -46,10 +46,7 @@ import org.apache.bcel.Const;
  */
 public final class StackMapEntry implements Node, Cloneable {
 
-    /**
-     * Empty array.
-     */
-    private static final StackMapType[] EMPTY_STACK_MAP_TYPE_ARRAY = {};
+    static final StackMapEntry[] EMPTY_ARRAY = {};
 
     private int frameType;
     private int byteCodeOffset;
@@ -118,8 +115,8 @@ public final class StackMapEntry implements Node, Cloneable {
     public StackMapEntry(final int byteCodeOffset, final int numberOfLocals, final StackMapType[] typesOfLocals, final int numberOfStackItems,
         final StackMapType[] typesOfStackItems, final ConstantPool constantPool) {
         this.byteCodeOffset = byteCodeOffset;
-        this.typesOfLocals = typesOfLocals != null ? typesOfLocals : EMPTY_STACK_MAP_TYPE_ARRAY;
-        this.typesOfStackItems = typesOfStackItems != null ? typesOfStackItems : EMPTY_STACK_MAP_TYPE_ARRAY;
+        this.typesOfLocals = typesOfLocals != null ? typesOfLocals : StackMapType.EMPTY_ARRAY;
+        this.typesOfStackItems = typesOfStackItems != null ? typesOfStackItems : StackMapType.EMPTY_ARRAY;
         this.constantPool = constantPool;
         if (numberOfLocals < 0) {
             throw new IllegalArgumentException("numberOfLocals < 0");
@@ -142,8 +139,8 @@ public final class StackMapEntry implements Node, Cloneable {
         final ConstantPool constantPool) {
         this.frameType = tag;
         this.byteCodeOffset = byteCodeOffset;
-        this.typesOfLocals = typesOfLocals != null ? typesOfLocals : EMPTY_STACK_MAP_TYPE_ARRAY;
-        this.typesOfStackItems = typesOfStackItems != null ? typesOfStackItems : EMPTY_STACK_MAP_TYPE_ARRAY;
+        this.typesOfLocals = typesOfLocals != null ? typesOfLocals : StackMapType.EMPTY_ARRAY;
+        this.typesOfStackItems = typesOfStackItems != null ? typesOfStackItems : StackMapType.EMPTY_ARRAY;
         this.constantPool = constantPool;
     }
 
@@ -350,11 +347,11 @@ public final class StackMapEntry implements Node, Cloneable {
     }
 
     public void setTypesOfLocals(final StackMapType[] types) {
-        typesOfLocals = types != null ? types : EMPTY_STACK_MAP_TYPE_ARRAY;
+        typesOfLocals = types != null ? types : StackMapType.EMPTY_ARRAY;
     }
 
     public void setTypesOfStackItems(final StackMapType[] types) {
-        typesOfStackItems = types != null ? types : EMPTY_STACK_MAP_TYPE_ARRAY;
+        typesOfStackItems = types != null ? types : StackMapType.EMPTY_ARRAY;
     }
 
     /**
diff --git a/src/main/java/org/apache/bcel/classfile/StackMapType.java b/src/main/java/org/apache/bcel/classfile/StackMapType.java
index 438fa5df..c9d6fdc4 100644
--- a/src/main/java/org/apache/bcel/classfile/StackMapType.java
+++ b/src/main/java/org/apache/bcel/classfile/StackMapType.java
@@ -31,6 +31,8 @@ import org.apache.bcel.Const;
  */
 public final class StackMapType implements Cloneable {
 
+    static final StackMapType[] EMPTY_ARRAY = {};
+
     private byte type;
     private int index = -1; // Index to CONSTANT_Class or offset
     private ConstantPool constantPool;


[commons-bcel] 10/11: org.apache.bcel.classfile.Signature constructors now throw ClassFormatException on invalid input

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit f9e50479e78176f6e27cd3d9861428967a974e04
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Tue Nov 22 07:50:07 2022 -0500

    org.apache.bcel.classfile.Signature constructors now throw
    ClassFormatException on invalid input
---
 src/changes/changes.xml                                | 2 +-
 src/main/java/org/apache/bcel/classfile/Signature.java | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2fc6901c..6825dc62 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -94,7 +94,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ModulePackages constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.NestHost constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.NestMembers constructors now throw ClassFormatException on invalid input.</action>
-      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Signature constructors now throw ClassFormatException on invalid length input.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.Signature constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.SourceFile constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.StackMap constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.StackMapEntry.StackMapEntry(DataInput, ConstantPool) reads signed instead of unsigned shorts from its DataInput.</action>
diff --git a/src/main/java/org/apache/bcel/classfile/Signature.java b/src/main/java/org/apache/bcel/classfile/Signature.java
index b1dbb764..e870066e 100644
--- a/src/main/java/org/apache/bcel/classfile/Signature.java
+++ b/src/main/java/org/apache/bcel/classfile/Signature.java
@@ -21,6 +21,7 @@ import java.io.DataInput;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
+import java.util.Objects;
 
 import org.apache.bcel.Const;
 import org.apache.bcel.util.Args;
@@ -175,6 +176,8 @@ public final class Signature extends Attribute {
     public Signature(final int nameIndex, final int length, final int signatureIndex, final ConstantPool constantPool) {
         super(Const.ATTR_SIGNATURE, nameIndex, Args.require(length, 2, "Signature length attribute"), constantPool);
         this.signatureIndex = signatureIndex;
+        // validate:
+        Objects.requireNonNull(constantPool.getConstantUtf8(signatureIndex), "constantPool.getConstantUtf8(signatureIndex)");
     }
 
     /**


[commons-bcel] 03/11: org.apache.bcel.classfile.ModuleMainClass constructors now throw ClassFormatException on invalid input

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit 57d1a3c6b8555383e17394dcb37f83f03424f208
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Mon Nov 21 16:22:26 2022 -0500

    org.apache.bcel.classfile.ModuleMainClass constructors now throw
    ClassFormatException on invalid input
---
 src/changes/changes.xml                                      | 1 +
 src/main/java/org/apache/bcel/classfile/ModuleMainClass.java | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ff0da0b4..a3b45240 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -106,6 +106,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariable constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariableTable constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariableTypeTable constructors now throw ClassFormatException on invalid input.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ModuleMainClass 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/ModuleMainClass.java b/src/main/java/org/apache/bcel/classfile/ModuleMainClass.java
index ae4b29c3..aa9686fd 100644
--- a/src/main/java/org/apache/bcel/classfile/ModuleMainClass.java
+++ b/src/main/java/org/apache/bcel/classfile/ModuleMainClass.java
@@ -22,6 +22,7 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 
 import org.apache.bcel.Const;
+import org.apache.bcel.util.Args;
 
 /**
  * This class is derived from <em>Attribute</em> and indicates the main class of a module. There may be at most one
@@ -55,7 +56,7 @@ public final class ModuleMainClass extends Attribute {
      */
     public ModuleMainClass(final int nameIndex, final int length, final int mainClassIndex, final ConstantPool constantPool) {
         super(Const.ATTR_NEST_MEMBERS, nameIndex, length, constantPool);
-        this.mainClassIndex = mainClassIndex;
+        this.mainClassIndex = Args.requireU2(mainClassIndex, "mainClassIndex");
     }
 
     /**


[commons-bcel] 04/11: org.apache.bcel.classfile.ModulePackages constructors now throw ClassFormatException on invalid input

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit cc9c33cb1bbdb8c166b791e8bed81fa7b82a9407
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Mon Nov 21 16:26:30 2022 -0500

    org.apache.bcel.classfile.ModulePackages constructors now throw
    ClassFormatException on invalid input
---
 src/changes/changes.xml                                     | 1 +
 src/main/java/org/apache/bcel/classfile/ModulePackages.java | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a3b45240..3fb0bf6e 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -107,6 +107,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariableTable constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariableTypeTable constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ModuleMainClass constructors now throw ClassFormatException on invalid input.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ModulePackages 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/ModulePackages.java b/src/main/java/org/apache/bcel/classfile/ModulePackages.java
index 212d96c1..c57e1e8a 100644
--- a/src/main/java/org/apache/bcel/classfile/ModulePackages.java
+++ b/src/main/java/org/apache/bcel/classfile/ModulePackages.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.util.Arrays;
 
 import org.apache.bcel.Const;
+import org.apache.bcel.util.Args;
 import org.apache.commons.lang3.ArrayUtils;
 
 /**
@@ -62,6 +63,7 @@ public final class ModulePackages extends Attribute {
     public ModulePackages(final int nameIndex, final int length, final int[] packageIndexTable, final ConstantPool constantPool) {
         super(Const.ATTR_MODULE_PACKAGES, nameIndex, length, constantPool);
         this.packageIndexTable = packageIndexTable != null ? packageIndexTable : ArrayUtils.EMPTY_INT_ARRAY;
+        Args.requireU2(this.packageIndexTable.length, "packageIndexTable.length");
     }
 
     /**


[commons-bcel] 06/11: org.apache.bcel.classfile.NestMembers constructors now throw ClassFormatException on invalid input

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit d7f558d934101b47274cdb6dd45c07141af97289
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Mon Nov 21 16:48:29 2022 -0500

    org.apache.bcel.classfile.NestMembers constructors now throw
    ClassFormatException on invalid input
---
 src/changes/changes.xml                                  | 1 +
 src/main/java/org/apache/bcel/classfile/NestMembers.java | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 541d5946..f6ca3f00 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -109,6 +109,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ModuleMainClass constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ModulePackages constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.NestHost constructors now throw ClassFormatException on invalid input.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.NestMembers 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/NestMembers.java b/src/main/java/org/apache/bcel/classfile/NestMembers.java
index 376a6a5b..38fb944c 100644
--- a/src/main/java/org/apache/bcel/classfile/NestMembers.java
+++ b/src/main/java/org/apache/bcel/classfile/NestMembers.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.util.Arrays;
 
 import org.apache.bcel.Const;
+import org.apache.bcel.util.Args;
 import org.apache.commons.lang3.ArrayUtils;
 
 /**
@@ -63,6 +64,7 @@ public final class NestMembers extends Attribute {
     public NestMembers(final int nameIndex, final int length, final int[] classes, final ConstantPool constantPool) {
         super(Const.ATTR_NEST_MEMBERS, nameIndex, length, constantPool);
         this.classes = classes != null ? classes : ArrayUtils.EMPTY_INT_ARRAY;
+        Args.requireU2(this.classes.length, "classes.length");
     }
 
     /**
@@ -90,7 +92,7 @@ public final class NestMembers extends Attribute {
     @Override
     public Attribute copy(final ConstantPool constantPool) {
         final NestMembers c = (NestMembers) clone();
-        if (classes != null) {
+        if (classes.length > 0) {
             c.classes = classes.clone();
         }
         c.setConstantPool(constantPool);
@@ -132,7 +134,7 @@ public final class NestMembers extends Attribute {
      * @return Length of classes table.
      */
     public int getNumberClasses() {
-        return classes == null ? 0 : classes.length;
+        return classes.length;
     }
 
     /**


[commons-bcel] 02/11: org.apache.bcel.classfile.LocalVariableTypeTable constructors now throw ClassFormatException on invalid input

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit b00e5e27606388fb99870877e16b6714c5942c20
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Mon Nov 21 16:21:52 2022 -0500

    org.apache.bcel.classfile.LocalVariableTypeTable constructors now throw
    ClassFormatException on invalid input
---
 src/changes/changes.xml                                             | 1 +
 src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 238f3320..ff0da0b4 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -105,6 +105,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LineNumber constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariable constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariableTable constructors now throw ClassFormatException on invalid input.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariableTypeTable 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/LocalVariableTypeTable.java b/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java
index 44876696..8a35c6ea 100644
--- a/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java
+++ b/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java
@@ -25,6 +25,7 @@ import java.util.Iterator;
 import java.util.stream.Stream;
 
 import org.apache.bcel.Const;
+import org.apache.bcel.util.Args;
 
 // The new table is used when generic types are about...
 
@@ -72,9 +73,10 @@ public class LocalVariableTypeTable extends Attribute implements Iterable<LocalV
         }
     }
 
-    public LocalVariableTypeTable(final int nameIndex, final int length, final LocalVariable[] localVariableTable, final ConstantPool constantPool) {
+    public LocalVariableTypeTable(final int nameIndex, final int length, final LocalVariable[] localVariableTypeTable, final ConstantPool constantPool) {
         super(Const.ATTR_LOCAL_VARIABLE_TYPE_TABLE, nameIndex, length, constantPool);
-        this.localVariableTypeTable = localVariableTable;
+        this.localVariableTypeTable = localVariableTypeTable != null ? localVariableTypeTable : LocalVariable.EMPTY_ARRAY;
+        Args.requireU2(this.localVariableTypeTable.length, "localVariableTypeTable.length");
     }
 
     public LocalVariableTypeTable(final LocalVariableTypeTable c) {