ppkarwasz commented on code in PR #715:
URL: https://github.com/apache/commons-compress/pull/715#discussion_r2392437472


##########
src/main/java/org/apache/commons/compress/utils/ArchiveUtils.java:
##########
@@ -261,6 +262,23 @@ public static String toString(final ArchiveEntry entry) {
         return sb.toString();
     }
 
+    /**
+     * Checks that the specified range is within the bounds of an array of the 
specified length.
+     *
+     * @param b           the array
+     * @param off         the starting offset of the range
+     * @param len         the length of the range
+     * @throws IndexOutOfBoundsException if {@code off} is negative, or {@code 
len} is negative, or {@code off + len} is greater than {@code arrayLength}
+     * @since 1.29.0
+     */
+    public static void checkFromIndexSize(final byte[] b, final int off, final 
int len) {
+        // TODO: replace with IOUtils.checkFromIndexSize, after upgrading to 
Commons IO 2.21.0
+        Objects.requireNonNull(b, "byte array");
+        if ((off | len) < 0 || b.length - len < off) {
+            throw new IndexOutOfBoundsException(String.format("Range [%s, %<s 
+ %s) out of bounds for length %s", off, len, b.length));

Review Comment:
   `%<s` references the previous and first argument: `off`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to