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/10/01 15:00:39 UTC

[commons-bcel] 03/04: org.apache.bcel.classfile.Signature.translate(String) does not detect EOF correctly

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 5e6505fad8048ff090e22a9b54ed252b9454f3b0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Oct 1 10:42:31 2022 -0400

    org.apache.bcel.classfile.Signature.translate(String) does not detect
    EOF correctly
---
 src/changes/changes.xml                                | 1 +
 src/main/java/org/apache/bcel/classfile/Signature.java | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 60096c46..4bde59d8 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -89,6 +89,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="fix" dev="ggregory" due-to="Michael Ernst">Fix typos #140.</action>
       <action issue="BCEL-363" type="fix" dev="ggregory" due-to="Richard Atkins, Gary Gregory">Enforce MAX_CP_ENTRIES in ConstantPoolGen and ConstantPool.dump #147.</action>
       <action                  type="fix" dev="ggregory" due-to="Arturo Bernal, Gary Gregory">Minor Changes #99.</action>
+      <action                  type="fix" dev="ggregory" due-to="Arturo Bernal, Gary Gregory">org.apache.bcel.classfile.Signature.translate(String) does not detect EOF correctly.</action>
       <!-- ADD -->
       <action                  type="add" dev="ggregory">Add github/codeql-action.</action>
       <action                  type="add" dev="ggregory" due-to="Gary Gregory">Make Annotations implement Iterable&lt;AnnotationEntry&gt;.</action>
diff --git a/src/main/java/org/apache/bcel/classfile/Signature.java b/src/main/java/org/apache/bcel/classfile/Signature.java
index 96cb0ddf..11c3791c 100644
--- a/src/main/java/org/apache/bcel/classfile/Signature.java
+++ b/src/main/java/org/apache/bcel/classfile/Signature.java
@@ -114,7 +114,11 @@ public final class Signature extends Attribute {
                 ch = in.read();
             }
             if (ch == ':') { // Ok, formal parameter
-                in.skip("Ljava/lang/Object".length());
+                final int skipExpected = "Ljava/lang/Object".length();
+                final long skipActual = in.skip(skipExpected);
+                if (skipActual != skipExpected) {
+                    throw new IllegalStateException(String.format("Unexpected skip: expected=%,d, actual=%,d", skipExpected, skipActual));
+                }
                 buf.append(buf2);
                 ch = in.read();
                 in.unread();