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 2025/08/10 11:14:05 UTC
(commons-compress) branch master updated (d268e81ac -> 6e66a6946)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
from d268e81ac Uniform handling of special tar records in `TarFile` and `TarArchiveInputStream` (#684)
new af466084e Extract internal constant
new 6b902dead Merge branch 'master' of https://github.com/apache/commons-compress.git
new fb1c821ae Drop no-op code in org.apache.commons.compress.archivers.zip
new 806e42422 Drop no-op code in org.apache.commons.compress.archivers.tar
new 45075dc3b Re-org latest action
new ae8833381 Sort members
new 6e66a6946 Make private instance variable final
The 7 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 | 2 +-
.../compress/archivers/ArchiveException.java | 32 +--
.../archivers/ar/ArArchiveInputStream.java | 27 +--
.../compress/archivers/tar/TarArchiveEntry.java | 5 +-
.../commons/compress/archivers/tar/TarFile.java | 2 +-
.../commons/compress/archivers/tar/TarUtils.java | 250 ++++++++++-----------
.../archivers/zip/X5455_ExtendedTimestamp.java | 2 -
.../zip/Zip64ExtendedInformationExtraField.java | 4 -
.../archivers/zip/ZipArchiveInputStream.java | 1 -
.../compress/archivers/zip/ZipFileTest.java | 10 +-
10 files changed, 158 insertions(+), 177 deletions(-)
(commons-compress) 07/07: Make private instance variable final
Posted by gg...@apache.org.
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-compress.git
commit 6e66a6946fea986cbc4d8755c999ddc82d595beb
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 10 07:13:59 2025 -0400
Make private instance variable final
---
src/main/java/org/apache/commons/compress/archivers/tar/TarFile.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarFile.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarFile.java
index fd618dbcc..8143921c9 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarFile.java
@@ -172,7 +172,7 @@ private int readSparse(final long pos, final ByteBuffer buf, final int numToRead
private TarArchiveEntry currEntry;
// the global PAX header
- private Map<String, String> globalPaxHeaders = new HashMap<>();
+ private final Map<String, String> globalPaxHeaders = new HashMap<>();
private final Map<String, List<InputStream>> sparseInputStreams = new HashMap<>();
(commons-compress) 01/07: Extract internal constant
Posted by gg...@apache.org.
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-compress.git
commit af466084e7787daca7b3a0c93ffe73764e99d947
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Aug 9 16:58:46 2025 -0400
Extract internal constant
---
.../archivers/ar/ArArchiveInputStream.java | 27 ++++++++--------------
1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
index 2ff7f085f..28daa87e8 100644
--- a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
@@ -30,6 +30,7 @@
import org.apache.commons.compress.utils.ArchiveUtils;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.compress.utils.ParsingUtils;
+import org.apache.commons.lang3.ArrayUtils;
/**
* Implements the "ar" archive format as an input stream.
@@ -42,13 +43,9 @@ public class ArArchiveInputStream extends ArchiveInputStream<ArArchiveEntry> {
private static final int NAME_OFFSET = 0;
private static final int NAME_LEN = 16;
private static final int LAST_MODIFIED_OFFSET = NAME_LEN;
-
private static final int LAST_MODIFIED_LEN = 12;
-
private static final int USER_ID_OFFSET = LAST_MODIFIED_OFFSET + LAST_MODIFIED_LEN;
-
private static final int USER_ID_LEN = 6;
-
private static final int GROUP_ID_OFFSET = USER_ID_OFFSET + USER_ID_LEN;
private static final int GROUP_ID_LEN = 6;
private static final int FILE_MODE_OFFSET = GROUP_ID_OFFSET + GROUP_ID_LEN;
@@ -61,6 +58,11 @@ public class ArArchiveInputStream extends ArchiveInputStream<ArArchiveEntry> {
private static final String GNU_STRING_TABLE_NAME = "//";
private static final Pattern GNU_LONGNAME_PATTERN = Pattern.compile("^/\\d+");
+ /**
+ * Signature {@code 3c21 7261 6863 0a3e}
+ */
+ private static final byte[] SIGNATURE = { 0x21, 0x3c, 0x61, 0x72, 0x63, 0x68, 0x3e, 0x0a };
+
/**
* Does the name look like it is a long name (or a name containing spaces) as encoded by BSD ar?
* <p>
@@ -108,23 +110,12 @@ private static boolean isGNUStringTable(final String name) {
/**
* Checks if the signature matches ASCII "!<arch>" followed by a single LF control character
*
- * @param signature the bytes to check
+ * @param buffer the bytes to check
* @param length the number of bytes to check
* @return true, if this stream is an Ar archive stream, false otherwise
*/
- public static boolean matches(final byte[] signature, final int length) {
- // 3c21 7261 6863 0a3e
- // @formatter:off
- return length >= 8 &&
- signature[0] == 0x21 &&
- signature[1] == 0x3c &&
- signature[2] == 0x61 &&
- signature[3] == 0x72 &&
- signature[4] == 0x63 &&
- signature[5] == 0x68 &&
- signature[6] == 0x3e &&
- signature[7] == 0x0a;
- // @formatter:on
+ public static boolean matches(final byte[] buffer, final int length) {
+ return ArrayUtils.startsWith(buffer, SIGNATURE);
}
private long offset;
(commons-compress) 04/07: Drop no-op code in org.apache.commons.compress.archivers.tar
Posted by gg...@apache.org.
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-compress.git
commit 806e42422a0a930cbac3bbd2bf0323dce8d4fdae
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 10 07:07:19 2025 -0400
Drop no-op code in org.apache.commons.compress.archivers.tar
---
.../org/apache/commons/compress/archivers/tar/TarArchiveEntry.java | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
index c1c4fcb80..75e5ce3cb 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
@@ -1568,7 +1568,6 @@ private void parseUstarHeaderBlock(final Map<String, String> globalPaxHeaders, f
isExtended = TarUtils.parseBoolean(header, offset);
offset += ISEXTENDEDLEN_GNU;
realSize = TarUtils.parseOctal(header, offset, REALSIZELEN_GNU);
- offset += REALSIZELEN_GNU; // NOSONAR - assignment as documentation
break;
}
// Star format (Schily tar)
@@ -1583,7 +1582,6 @@ private void parseUstarHeaderBlock(final Map<String, String> globalPaxHeaders, f
aTime = fileTimeFromOptionalSeconds(parseOctalOrBinary(header, offset, ATIMELEN_XSTAR, lenient));
offset += ATIMELEN_XSTAR;
cTime = fileTimeFromOptionalSeconds(parseOctalOrBinary(header, offset, CTIMELEN_XSTAR, lenient));
- offset += CTIMELEN_XSTAR; // NOSONAR - assignment as documentation
break;
}
// Pure POSIX.1-1988 UStar format
@@ -1592,7 +1590,6 @@ private void parseUstarHeaderBlock(final Map<String, String> globalPaxHeaders, f
final String prefix = oldStyle
? TarUtils.parseName(header, offset, PREFIXLEN)
: TarUtils.parseName(header, offset, PREFIXLEN, encoding);
- offset += PREFIXLEN; // NOSONAR - assignment as documentation
// SunOS tar -E does not add / to directory names, so fix up to be consistent
if (isDirectory() && !name.endsWith("/")) {
name += "/";
@@ -2080,7 +2077,7 @@ public void writeEntryHeader(final byte[] outbuf, final ZipEncoding encoding, fi
// This makes it effectively XUSTAR, which guarantees compatibility with USTAR
offset = fill(0, offset, outbuf, XSTAR_MAGIC_LEN);
}
- offset = fill(0, offset, outbuf, outbuf.length - offset); // NOSONAR - assignment as documentation
+ fill(0, offset, outbuf, outbuf.length - offset);
final long chk = TarUtils.computeCheckSum(outbuf);
TarUtils.formatCheckSumOctalBytes(chk, outbuf, csOffset, CHKSUMLEN);
}
(commons-compress) 06/07: Sort members
Posted by gg...@apache.org.
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-compress.git
commit ae883338148f06220dda070a43ee0dfc0c1591da
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 10 07:12:24 2025 -0400
Sort members
---
.../compress/archivers/ArchiveException.java | 32 +--
.../commons/compress/archivers/tar/TarUtils.java | 250 ++++++++++-----------
.../compress/archivers/zip/ZipFileTest.java | 10 +-
3 files changed, 146 insertions(+), 146 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/archivers/ArchiveException.java b/src/main/java/org/apache/commons/compress/archivers/ArchiveException.java
index f550d629c..505183077 100644
--- a/src/main/java/org/apache/commons/compress/archivers/ArchiveException.java
+++ b/src/main/java/org/apache/commons/compress/archivers/ArchiveException.java
@@ -65,22 +65,6 @@ public static int addExact(final int x, final long y) throws ArchiveException {
return addExact(x, y, E_FUNCTION);
}
- /**
- * Delegates to {@link Math#toIntExact(long)} wrapping its {@link ArithmeticException} in our {@link ArchiveException}.
- *
- * @param value the long value.
- * @return the argument as an int.
- * @throws ArchiveException if the {@code argument} overflows an int.
- * @since 1.29.0
- */
- public static int toIntExact(final long value) throws ArchiveException {
- try {
- return Math.toIntExact(value);
- } catch (final ArithmeticException e) {
- throw new ArchiveException(e);
- }
- }
-
/**
* Delegates to {@link Math#addExact(long, long)} wrapping its {@link ArithmeticException} in our {@link ArchiveException}.
*
@@ -113,6 +97,22 @@ public static <T> T requireNonNull(final T obj, final Supplier<String> messageSu
return CompressException.requireNonNull(ArchiveException.class, obj, messageSupplier);
}
+ /**
+ * Delegates to {@link Math#toIntExact(long)} wrapping its {@link ArithmeticException} in our {@link ArchiveException}.
+ *
+ * @param value the long value.
+ * @return the argument as an int.
+ * @throws ArchiveException if the {@code argument} overflows an int.
+ * @since 1.29.0
+ */
+ public static int toIntExact(final long value) throws ArchiveException {
+ try {
+ return Math.toIntExact(value);
+ } catch (final ArithmeticException e) {
+ throw new ArchiveException(e);
+ }
+ }
+
/**
* Constructs an {@code ArchiveException} with {@code null} as its error detail message.
*
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
index fe6f299c6..b80198a70 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
@@ -82,6 +82,35 @@ public ByteBuffer encode(final String name) {
}
};
+ /**
+ * Applies the PAX headers and sparse headers to the given tar entry.
+ *
+ * @param entry the tar entry to handle
+ * @param paxHeaders per file PAX headers
+ * @param sparseHeaders per file sparse headers
+ * @param globalPaxHeaders global PAX headers
+ * @param globalSparseHeaders global sparse headers
+ * @throws IOException if an I/O error occurs while reading the entry
+ */
+ static void applyPaxHeadersToEntry(
+ final TarArchiveEntry entry,
+ final Map<String, String> paxHeaders,
+ final List<TarArchiveStructSparse> sparseHeaders,
+ final Map<String, String> globalPaxHeaders,
+ final List<TarArchiveStructSparse> globalSparseHeaders) throws IOException {
+ // Apply PAX headers to the entry
+ entry.updateEntryFromPaxHeaders(globalPaxHeaders);
+ entry.updateEntryFromPaxHeaders(paxHeaders);
+ // Apply sparse headers to the entry, unless it is a pre-pax GNU sparse entry
+ if (!entry.isOldGNUSparse()) {
+ entry.setSparseHeaders(globalSparseHeaders);
+ if (!sparseHeaders.isEmpty()) {
+ // If there are local sparse headers, they override the global ones
+ entry.setSparseHeaders(sparseHeaders);
+ }
+ }
+ }
+
/**
* Computes the checksum of a tar entry header.
*
@@ -312,6 +341,74 @@ public static void formatUnsignedOctalString(final long value, final byte[] buff
Arrays.fill(buffer, offset, offset + remaining + 1, (byte) '0');
}
+ /**
+ * Processes a special tar record and updates the provided PAX global and per entry headers.
+ * <p>
+ * This method reads the content of the special entry from the input stream and updates the relevant metadata structures.
+ * </p>
+ * <p>
+ * GNU long file and link names are translated to their equivalent PAX headers.
+ * </p>
+ *
+ * @param input the input stream from which to read the special tar entry content
+ * @param encoding the encoding to use for reading names
+ * @param entry the tar entry to handle
+ * @param paxHeaders the map to update with PAX headers
+ * @param sparseHeaders the list to update with sparse headers
+ * @param globalPaxHeaders the map to update with global PAX headers
+ * @param globalSparseHeaders the list to update with global sparse headers
+ * @throws IOException if an I/O error occurs while reading the entry
+ */
+ static void handleSpecialTarRecord(
+ final InputStream input,
+ final ZipEncoding encoding,
+ final TarArchiveEntry entry,
+ final Map<String, String> paxHeaders,
+ final List<TarArchiveStructSparse> sparseHeaders,
+ final Map<String, String> globalPaxHeaders,
+ final List<TarArchiveStructSparse> globalSparseHeaders)
+ throws IOException {
+ if (entry.isGNULongLinkEntry()) {
+ // GNU long link entry: read and store the link path
+ final String longLinkName = readLongName(input, encoding, entry);
+ paxHeaders.put("linkpath", longLinkName);
+ } else if (entry.isGNULongNameEntry()) {
+ // GNU long name entry: read and store the file path
+ final String longName = readLongName(input, encoding, entry);
+ paxHeaders.put("path", longName);
+ } else if (entry.isGlobalPaxHeader()) {
+ // Global PAX header: clear and update global PAX and sparse headers
+ globalSparseHeaders.clear();
+ globalPaxHeaders.clear();
+ globalPaxHeaders.putAll(parsePaxHeaders(input, globalSparseHeaders, globalPaxHeaders, entry.getSize()));
+ } else if (entry.isPaxHeader()) {
+ // PAX header: clear and update local PAX and sparse headers, parse GNU sparse headers if present
+ sparseHeaders.clear();
+ paxHeaders.clear();
+ paxHeaders.putAll(parsePaxHeaders(input, sparseHeaders, globalPaxHeaders, entry.getSize()));
+ if (paxHeaders.containsKey(TarGnuSparseKeys.MAP)) {
+ sparseHeaders.addAll(parseFromPAX01SparseHeaders(paxHeaders.get(TarGnuSparseKeys.MAP)));
+ }
+ }
+ }
+
+ /**
+ * Determines if the given tar entry is a special tar record.
+ * <p>
+ * Special tar records are used to store metadata such as long file names, long link names, or PAX headers
+ * that apply to the entire archive or to the next file entry.
+ * </p>
+ *
+ * @param entry the tar record to check
+ * @return {@code true} if the entry is a special tar record, {@code false} otherwise
+ */
+ static boolean isSpecialTarRecord(final TarArchiveEntry entry) {
+ return entry.isGNULongLinkEntry()
+ || entry.isGNULongNameEntry()
+ || entry.isGlobalPaxHeader()
+ || entry.isPaxHeader();
+ }
+
private static long parseBinaryBigInteger(final byte[] buffer, final int offset, final int length, final boolean negative) {
final byte[] remainder = new byte[length - 1];
System.arraycopy(buffer, offset + 1, remainder, 0, length - 1);
@@ -776,6 +873,34 @@ private static long[] readLineOfNumberForPax1x(final InputStream inputStream) th
return new long[] { result, bytesRead };
}
+ /**
+ * Reads a long name (file or link name) from the input stream for a special tar record.
+ *
+ * @param input the input stream from which to read the long name
+ * @param encoding the encoding to use for reading the name
+ * @param entry the tar entry containing the long name
+ * @return the decoded long name, with trailing NULs removed
+ * @throws IOException if an I/O error occurs or the entry is truncated
+ * @throws ArchiveException if the entry size is invalid
+ */
+ private static String readLongName(final InputStream input, final ZipEncoding encoding, final TarArchiveEntry entry)
+ throws IOException {
+ final long size = entry.getSize();
+ if (size > Integer.MAX_VALUE) {
+ throw new ArchiveException("Invalid long name size: " + entry.getSize());
+ }
+ final int sizeInt = (int) size;
+ final byte[] buffer = new byte[sizeInt];
+ if (IOUtils.readFully(input, buffer, 0, sizeInt) < sizeInt) {
+ throw new ArchiveException("TAR entry is truncated.");
+ }
+ int length = buffer.length;
+ while (length > 0 && buffer[length - 1] == 0) {
+ length--;
+ }
+ return encoding.decode(Arrays.copyOf(buffer, length));
+ }
+
/**
* @since 1.21
*/
@@ -831,131 +956,6 @@ public static boolean verifyCheckSum(final byte[] header) {
return storedSum == unsignedSum || storedSum == signedSum;
}
- /**
- * Determines if the given tar entry is a special tar record.
- * <p>
- * Special tar records are used to store metadata such as long file names, long link names, or PAX headers
- * that apply to the entire archive or to the next file entry.
- * </p>
- *
- * @param entry the tar record to check
- * @return {@code true} if the entry is a special tar record, {@code false} otherwise
- */
- static boolean isSpecialTarRecord(final TarArchiveEntry entry) {
- return entry.isGNULongLinkEntry()
- || entry.isGNULongNameEntry()
- || entry.isGlobalPaxHeader()
- || entry.isPaxHeader();
- }
-
- /**
- * Processes a special tar record and updates the provided PAX global and per entry headers.
- * <p>
- * This method reads the content of the special entry from the input stream and updates the relevant metadata structures.
- * </p>
- * <p>
- * GNU long file and link names are translated to their equivalent PAX headers.
- * </p>
- *
- * @param input the input stream from which to read the special tar entry content
- * @param encoding the encoding to use for reading names
- * @param entry the tar entry to handle
- * @param paxHeaders the map to update with PAX headers
- * @param sparseHeaders the list to update with sparse headers
- * @param globalPaxHeaders the map to update with global PAX headers
- * @param globalSparseHeaders the list to update with global sparse headers
- * @throws IOException if an I/O error occurs while reading the entry
- */
- static void handleSpecialTarRecord(
- final InputStream input,
- final ZipEncoding encoding,
- final TarArchiveEntry entry,
- final Map<String, String> paxHeaders,
- final List<TarArchiveStructSparse> sparseHeaders,
- final Map<String, String> globalPaxHeaders,
- final List<TarArchiveStructSparse> globalSparseHeaders)
- throws IOException {
- if (entry.isGNULongLinkEntry()) {
- // GNU long link entry: read and store the link path
- final String longLinkName = readLongName(input, encoding, entry);
- paxHeaders.put("linkpath", longLinkName);
- } else if (entry.isGNULongNameEntry()) {
- // GNU long name entry: read and store the file path
- final String longName = readLongName(input, encoding, entry);
- paxHeaders.put("path", longName);
- } else if (entry.isGlobalPaxHeader()) {
- // Global PAX header: clear and update global PAX and sparse headers
- globalSparseHeaders.clear();
- globalPaxHeaders.clear();
- globalPaxHeaders.putAll(parsePaxHeaders(input, globalSparseHeaders, globalPaxHeaders, entry.getSize()));
- } else if (entry.isPaxHeader()) {
- // PAX header: clear and update local PAX and sparse headers, parse GNU sparse headers if present
- sparseHeaders.clear();
- paxHeaders.clear();
- paxHeaders.putAll(parsePaxHeaders(input, sparseHeaders, globalPaxHeaders, entry.getSize()));
- if (paxHeaders.containsKey(TarGnuSparseKeys.MAP)) {
- sparseHeaders.addAll(parseFromPAX01SparseHeaders(paxHeaders.get(TarGnuSparseKeys.MAP)));
- }
- }
- }
-
- /**
- * Applies the PAX headers and sparse headers to the given tar entry.
- *
- * @param entry the tar entry to handle
- * @param paxHeaders per file PAX headers
- * @param sparseHeaders per file sparse headers
- * @param globalPaxHeaders global PAX headers
- * @param globalSparseHeaders global sparse headers
- * @throws IOException if an I/O error occurs while reading the entry
- */
- static void applyPaxHeadersToEntry(
- final TarArchiveEntry entry,
- final Map<String, String> paxHeaders,
- final List<TarArchiveStructSparse> sparseHeaders,
- final Map<String, String> globalPaxHeaders,
- final List<TarArchiveStructSparse> globalSparseHeaders) throws IOException {
- // Apply PAX headers to the entry
- entry.updateEntryFromPaxHeaders(globalPaxHeaders);
- entry.updateEntryFromPaxHeaders(paxHeaders);
- // Apply sparse headers to the entry, unless it is a pre-pax GNU sparse entry
- if (!entry.isOldGNUSparse()) {
- entry.setSparseHeaders(globalSparseHeaders);
- if (!sparseHeaders.isEmpty()) {
- // If there are local sparse headers, they override the global ones
- entry.setSparseHeaders(sparseHeaders);
- }
- }
- }
-
- /**
- * Reads a long name (file or link name) from the input stream for a special tar record.
- *
- * @param input the input stream from which to read the long name
- * @param encoding the encoding to use for reading the name
- * @param entry the tar entry containing the long name
- * @return the decoded long name, with trailing NULs removed
- * @throws IOException if an I/O error occurs or the entry is truncated
- * @throws ArchiveException if the entry size is invalid
- */
- private static String readLongName(final InputStream input, final ZipEncoding encoding, final TarArchiveEntry entry)
- throws IOException {
- final long size = entry.getSize();
- if (size > Integer.MAX_VALUE) {
- throw new ArchiveException("Invalid long name size: " + entry.getSize());
- }
- final int sizeInt = (int) size;
- final byte[] buffer = new byte[sizeInt];
- if (IOUtils.readFully(input, buffer, 0, sizeInt) < sizeInt) {
- throw new ArchiveException("TAR entry is truncated.");
- }
- int length = buffer.length;
- while (length > 0 && buffer[length - 1] == 0) {
- length--;
- }
- return encoding.decode(Arrays.copyOf(buffer, length));
- }
-
/** Prevents instantiation. */
private TarUtils() {
}
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
index 46ee6d278..06adb90f2 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
@@ -268,6 +268,11 @@ void testAlternativeZstdInputStream() throws Exception {
}
}
+ @Test
+ void testBuidlerGet() throws IOException {
+ assertThrows(ZipException.class, () -> ZipFile.builder().setPath("src/test/resources/org/apache/commons/compress/zip/getNextZipEntry.bin").get());
+ }
+
@Test
void testCDOrder() throws Exception {
readOrderTest();
@@ -380,11 +385,6 @@ void testCreateBoundedInputStream() throws IOException {
}
}
- @Test
- void testBuidlerGet() throws IOException {
- assertThrows(ZipException.class, () -> ZipFile.builder().setPath("src/test/resources/org/apache/commons/compress/zip/getNextZipEntry.bin").get());
- }
-
/**
* Test correct population of header and data offsets when they are written after stream.
*/
(commons-compress) 02/07: Merge branch 'master' of https://github.com/apache/commons-compress.git
Posted by gg...@apache.org.
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-compress.git
commit 6b902dead33799ca4a57ce01682302bb3bca00f8
Merge: af466084e d268e81ac
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 10 07:02:10 2025 -0400
Merge branch 'master' of https://github.com/apache/commons-compress.git
src/changes/changes.xml | 1 +
.../compress/archivers/tar/TarArchiveEntry.java | 124 +++++++----
.../archivers/tar/TarArchiveInputStream.java | 209 +++++++------------
.../commons/compress/archivers/tar/TarFile.java | 227 +++++----------------
.../commons/compress/archivers/tar/TarUtils.java | 126 +++++++++++-
5 files changed, 334 insertions(+), 353 deletions(-)
(commons-compress) 03/07: Drop no-op code in org.apache.commons.compress.archivers.zip
Posted by gg...@apache.org.
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-compress.git
commit fb1c821ae3ccb4dd4a85514d42202a5cc6cc95b8
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 10 07:07:05 2025 -0400
Drop no-op code in org.apache.commons.compress.archivers.zip
---
.../commons/compress/archivers/zip/X5455_ExtendedTimestamp.java | 2 --
.../compress/archivers/zip/Zip64ExtendedInformationExtraField.java | 4 ----
.../apache/commons/compress/archivers/zip/ZipArchiveInputStream.java | 1 -
3 files changed, 7 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java b/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java
index 84168d593..6e31e9d35 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java
@@ -320,7 +320,6 @@ public byte[] getLocalFileDataData() {
if (bit2_createTimePresent && createTime != null) {
data[0] |= CREATE_TIME_BIT;
System.arraycopy(createTime.getBytes(), 0, data, pos, 4);
- pos += 4; // NOSONAR - assignment as documentation
}
return data;
}
@@ -452,7 +451,6 @@ public void parseFromLocalFileData(final byte[] data, int offset, final int leng
}
if (bit2_createTimePresent && offset + 4 <= len) {
createTime = new ZipLong(data, offset);
- offset += 4; // NOSONAR - assignment as documentation
} else {
bit2_createTimePresent = false;
}
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java b/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java
index 11f1d8135..7093512d7 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java
@@ -119,7 +119,6 @@ public byte[] getCentralDirectoryData() {
}
if (diskStart != null) {
System.arraycopy(diskStart.getBytes(), 0, data, off, WORD);
- off += WORD; // NOSONAR - assignment as documentation
}
return data;
}
@@ -238,8 +237,6 @@ public void parseFromLocalFileData(final byte[] buffer, int offset, final int le
}
if (remaining >= WORD) {
diskStart = new ZipLong(buffer, offset);
- offset += WORD; // NOSONAR - assignment as documentation
- remaining -= WORD; // NOSONAR - assignment as documentation
}
}
@@ -281,7 +278,6 @@ public void reparseCentralDirectoryData(final boolean hasUncompressedSize, final
}
if (hasDiskStart) {
diskStart = new ZipLong(rawCentralDirectoryData, offset);
- offset += WORD; // NOSONAR - assignment as documentation
}
}
}
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
index ba4fcea8f..c543da87c 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
@@ -745,7 +745,6 @@ public ZipArchiveEntry getNextZipEntry() throws IOException {
off += SHORT;
final int extraLen = ZipShort.getValue(lfhBuf, off);
- off += SHORT; // NOSONAR - assignment as documentation
final byte[] fileName = readRange(fileNameLen);
current.entry.setName(entryEncoding.decode(fileName), fileName);
(commons-compress) 05/07: Re-org latest action
Posted by gg...@apache.org.
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-compress.git
commit 45075dc3b620ee0b6869a99b5c11b4b4811cfc2c
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 10 07:12:18 2025 -0400
Re-org latest action
---
src/changes/changes.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4ffb33fac..8733be649 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -68,6 +68,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.commons.compress.archivers.zip.ExplodingInputStream now throws ArchiveException instead of ArithmeticException.</action>
<!-- FIX tar -->
<action type="fix" dev="ggregory" due-to="Tyler Nighswander, Gary Gregory">org.apache.commons.compress.archivers.tar.TarArchiveInputStream.paxHeaders() now throws an ArchiveException if there are too many PAX headers; override with -D'TarArchiveInputStream.MAX_PAX_HEADER_DEPTH=850'.</action>
+ <action type="fix" dev="pkarwasz" due-to="Tyler Nighswander, Piotr P. Karwasz, Gary Gregory">>Uniform handling of special tar records in TarFile and TarArchiveInputStream.</action>
<!-- FIX ar -->
<action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.commons.compress.archivers.ar.ArArchiveInputStream.readGNUStringTable(byte[], int, int) now provides a better exception message, wrapping the underlying exception.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.commons.compress.archivers.ar.ArArchiveInputStream.read(byte[], int, int) now throws ArchiveException instead of ArithmeticException.</action>
@@ -103,7 +104,6 @@ The <action> type attribute can be add,update,fix,remove.
<action type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.compress.harmony.pack200.Pack200Exception.addExact(int, long).</action>
<action type="add" issue="COMPRESS-705" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream.Builder.setIgnoreExtraField(boolean).</action>
<!-- UPDATE -->
- <action type="update" dev="pkarwasz">Uniform handling of special tar records in `TarFile` and `TarArchiveInputStream`.</action>
</release>
<release version="1.28.0" date="2025-07-26" description="This is a feature and maintenance release. Java 8 or later is required.">
<!-- FIX -->