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 d3209d933ffdbaa1406e6c0b51125852a9c05f76 Author: Gary David Gregory (Code signing key) <ggreg...@apache.org> AuthorDate: Mon Nov 21 10:53:00 2022 -0500 org.apache.bcel.classfile.CodeException constructors now throw ClassFormatException on invalid input --- src/changes/changes.xml | 3 ++- .../org/apache/bcel/classfile/CodeException.java | 29 +++++++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 30a26c71..9a9f46c2 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -97,8 +97,9 @@ The <action> type attribute can be add,update,fix,remove. <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="add" 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 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.CodeException 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/CodeException.java b/src/main/java/org/apache/bcel/classfile/CodeException.java index 54725fc8..d5b16ce6 100644 --- a/src/main/java/org/apache/bcel/classfile/CodeException.java +++ b/src/main/java/org/apache/bcel/classfile/CodeException.java @@ -22,11 +22,32 @@ import java.io.IOException; import org.apache.bcel.Const; import org.apache.bcel.Constants; +import org.apache.bcel.util.Args; /** * This class represents an entry in the exception table of the <em>Code</em> attribute and is used only there. It * contains a range in which a particular exception handler is active. * + * <pre> + * Code_attribute { + * u2 attribute_name_index; + * u4 attribute_length; + * u2 max_stack; + * u2 max_locals; + * u4 code_length; + * u1 code[code_length]; + * u2 exception_table_length; + * { + * u2 start_pc; + * u2 end_pc; + * u2 handler_pc; + * u2 catch_type; + * } exception_table[exception_table_length]; + * u2 attributes_count; + * attribute_info attributes[attributes_count]; + * } + * </pre> + * * @see Code */ public final class CodeException implements Cloneable, Node, Constants { @@ -81,10 +102,10 @@ public final class CodeException implements Cloneable, Node, Constants { * caught. */ public CodeException(final int startPc, final int endPc, final int handlerPc, final int catchType) { - this.startPc = startPc; - this.endPc = endPc; - this.handlerPc = handlerPc; - this.catchType = catchType; + this.startPc = Args.requireU2(startPc, "startPc"); + this.endPc = Args.requireU2(endPc, "endPc"); + this.handlerPc = Args.requireU2(handlerPc, "handlerPc"); + this.catchType = Args.requireU2(catchType, "catchType"); } /**