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 2026/07/10 13:37:56 UTC
(commons-compress) branch master updated (ae30dac8f -> 2d58dc3ff)
This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
from ae30dac8f reject negative element counts in BandSet band decoding (#782)
new 221071c01 Reject negative element counts in BandSet band decoding (#782).
new 4095ce139 Don't allocate array before illegal value detection.
new 26bd84e32 Internal refactoring for duplication.
new 2d58dc3ff Internal refactoring array constant.
The 4 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 | 1 +
.../compress/harmony/unpack200/BandSet.java | 42 ++++++++++------------
2 files changed, 19 insertions(+), 24 deletions(-)
(commons-compress) 02/04: Don't allocate array before illegal value detection.
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 4095ce1396709d62a8e49d72811f327b87a29506
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jul 10 09:32:23 2026 -0400
Don't allocate array before illegal value detection.
---
.../java/org/apache/commons/compress/harmony/unpack200/BandSet.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
index 1c5552529..aa75dbf00 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
@@ -550,7 +550,6 @@ public long[][] parseFlags(final String name, final InputStream in, final int[]
return new long[][] { {} };
}
int sum = 0;
- final long[][] result = new long[count][];
for (int i = 0; i < count; i++) {
if (counts[i] < 0) {
throw new Pack200Exception("count < 0");
@@ -563,8 +562,8 @@ public long[][] parseFlags(final String name, final InputStream in, final int[]
hi = decodeBandInt(name, in, hiCodec, sum);
}
lo = decodeBandInt(name, in, loCodec, sum);
-
int index = 0;
+ final long[][] result = new long[count][];
for (int i = 0; i < count; i++) {
result[i] = new long[counts[i]];
for (int j = 0; j < result[i].length; j++) {
(commons-compress) 01/04: Reject negative element counts in BandSet band decoding (#782).
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 221071c01854ab7181622771f97625d25cc91b78
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jul 10 09:27:05 2026 -0400
Reject negative element counts in BandSet band decoding (#782).
---
src/changes/changes.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 7c9c29007..c6f050bf0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -97,6 +97,7 @@ The <action> type attribute can be add,update,fix,remove.
<!-- FIX unpack200 -->
<action type="fix" dev="ggregory" due-to="Gary Gregory, Stanislav Fort">org.apache.commons.compress.harmony.unpack200 now throws Pack200Exception, IllegalArgumentException, and IllegalStateException instead of other runtime exceptions and Error.</action>
<action type="fix" dev="pkarwasz" due-to="Piotr P. Karwasz">Enforce strict attribute layout parsing in Pack200.</action>
+ <action type="fix" dev="ggregory" due-to="KALI 834X, Gary Gregory">Reject negative element counts in BandSet band decoding (#782).</action>
<!-- FIX pack200 -->
<action type="fix" dev="ggregory" due-to="Gary Gregory, Igor Morgenstern">org.apache.commons.compress.harmony.pack200 now throws Pack200Exception, IllegalArgumentException, IllegalStateException, instead of other runtime exceptions and Error.</action>
<action type="fix" dev="ppkarwasz" due-to="Raeps">Extract duplicate code in org.apache.commons.compress.harmony.pack200.IntList.</action>
(commons-compress) 03/04: Internal refactoring for duplication.
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 26bd84e32c73007350dfb3482b41f7ce2917e3b3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jul 10 09:37:38 2026 -0400
Internal refactoring for duplication.
---
.../compress/harmony/unpack200/BandSet.java | 35 +++++++++-------------
1 file changed, 14 insertions(+), 21 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
index aa75dbf00..1b7436948 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
@@ -47,6 +47,17 @@
*/
public abstract class BandSet {
+ static int sumPositive(final int[] counts) throws Pack200Exception {
+ int totalCount = 0;
+ for (final int count : counts) {
+ if (count < 0) {
+ throw new Pack200Exception("count < 0");
+ }
+ totalCount += count;
+ }
+ return totalCount;
+ }
+
/**
* Segment.
*/
@@ -149,13 +160,7 @@ public int[] decodeBandInt(final String name, final InputStream in, final BHSDCo
public int[][] decodeBandInt(final String name, final InputStream in, final BHSDCodec defaultCodec, final int[] counts)
throws IOException, Pack200Exception {
final int[][] result = new int[counts.length][];
- int totalCount = 0;
- for (final int count : counts) {
- if (count < 0) {
- throw new Pack200Exception("count < 0");
- }
- totalCount += count;
- }
+ final int totalCount = sumPositive(counts);
final int[] twoDResult = decodeBandInt(name, in, defaultCodec, totalCount);
int index = 0;
for (int i = 0; i < result.length; i++) {
@@ -549,13 +554,7 @@ public long[][] parseFlags(final String name, final InputStream in, final int[]
if (count == 0) {
return new long[][] { {} };
}
- int sum = 0;
- for (int i = 0; i < count; i++) {
- if (counts[i] < 0) {
- throw new Pack200Exception("count < 0");
- }
- sum += counts[i];
- }
+ final int sum = sumPositive(counts);
int[] hi = null;
final int[] lo;
if (hiCodec != null) {
@@ -633,13 +632,7 @@ public String[][] parseReferences(final String name, final InputStream in, final
if (count == 0) {
return new String[][] { {} };
}
- int sum = 0;
- for (int i = 0; i < count; i++) {
- if (counts[i] < 0) {
- throw new Pack200Exception("count < 0");
- }
- sum += counts[i];
- }
+ final int sum = sumPositive(counts);
// TODO Merge the decode and parsing of a multiple structure into one
final int[] indices = decodeBandInt(name, in, codec, sum);
final String[] result1 = new String[sum];
(commons-compress) 04/04: Internal refactoring array constant.
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 2d58dc3ffd0647bb40fbddbbcbd411b8e40b22f8
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jul 10 09:37:50 2026 -0400
Internal refactoring array constant.
---
.../java/org/apache/commons/compress/harmony/unpack200/BandSet.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
index 1b7436948..93c218e14 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
@@ -47,6 +47,8 @@
*/
public abstract class BandSet {
+ private static final String[][] EMPTY_STRINGS = new String[][] { {} };
+
static int sumPositive(final int[] counts) throws Pack200Exception {
int totalCount = 0;
for (final int count : counts) {
@@ -630,7 +632,7 @@ public String[][] parseReferences(final String name, final InputStream in, final
throws IOException, Pack200Exception {
final int count = counts.length;
if (count == 0) {
- return new String[][] { {} };
+ return EMPTY_STRINGS;
}
final int sum = sumPositive(counts);
// TODO Merge the decode and parsing of a multiple structure into one