|
| 1 | +From 74d2bf8a7f2ad282ebd0055c0f41ed2e6d1f5ea5 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Sudipta Pandit <sudpandit@microsoft.com> |
| 3 | +Date: Fri, 16 May 2025 17:10:24 +0530 |
| 4 | +Subject: [PATCH] Backport patch for CVE-2024-25710 |
| 5 | + |
| 6 | +Upstream Reference: https://github.com/apache/commons-compress/commit/8a9a5847c04ae39a1d45b365f8bb82022466067d |
| 7 | +--- |
| 8 | + .../commons/compress/archivers/dump/DumpArchiveUtil.java | 6 ++++++ |
| 9 | + .../commons/compress/archivers/dump/TapeInputStream.java | 3 +++ |
| 10 | + 2 files changed, 9 insertions(+) |
| 11 | + |
| 12 | +diff --git a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java |
| 13 | +index 80cd93588..0484d329b 100644 |
| 14 | +--- a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java |
| 15 | ++++ b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java |
| 16 | +@@ -83,6 +83,9 @@ public static final long convert64(final byte[] buffer, final int offset) { |
| 17 | + */ |
| 18 | + static String decode(final ZipEncoding encoding, final byte[] b, final int offset, final int len) |
| 19 | + throws IOException { |
| 20 | ++ if (offset > offset + len) { |
| 21 | ++ throw new IOException("Invalid offset/length combination"); |
| 22 | ++ } |
| 23 | + return encoding.decode(Arrays.copyOfRange(b, offset, offset + len)); |
| 24 | + } |
| 25 | + |
| 26 | +@@ -103,6 +106,9 @@ public static final int getIno(final byte[] buffer) { |
| 27 | + * @return Whether the buffer contains a tape segment header. |
| 28 | + */ |
| 29 | + public static final boolean verify(final byte[] buffer) { |
| 30 | ++ if (buffer == null) { |
| 31 | ++ return false; |
| 32 | ++ } |
| 33 | + // verify magic. for now only accept NFS_MAGIC. |
| 34 | + final int magic = convert32(buffer, 24); |
| 35 | + |
| 36 | +diff --git a/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java b/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java |
| 37 | +index 08d23f7f3..85735a189 100644 |
| 38 | +--- a/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java |
| 39 | ++++ b/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java |
| 40 | +@@ -311,6 +311,9 @@ public void resetBlockSize(final int recsPerBlock, final boolean isCompressed) |
| 41 | + + " records found, must be at least 1"); |
| 42 | + } |
| 43 | + blockSize = RECORD_SIZE * recsPerBlock; |
| 44 | ++ if (blockSize < 1) { |
| 45 | ++ throw new IOException("Block size cannot be less than or equal to 0: " + blockSize); |
| 46 | ++ } |
| 47 | + |
| 48 | + // save first block in case we need it again |
| 49 | + final byte[] oldBuffer = blockBuffer; |
| 50 | +-- |
| 51 | +2.34.1 |
| 52 | + |
0 commit comments