COMPRESS-450 headerErrorOccurred need to be written somewhere, avoid NPE
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
index d5d9ca0..4751ce5 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
@@ -286,7 +286,7 @@
byte[] headerBuf = getRecord();
if (headerErrorOccurred) {
- do {
+ while (headerBuf != null) {
try {
if (TarUtils.verifyCheckSum(headerBuf)) {
break;
@@ -295,8 +295,10 @@
// next record is not a valid tar header either
}
entryOffset += recordSize;
- } while ((headerBuf = getRecord()) != null);
+ headerBuf = getRecord();
+ }
}
+ headerErrorOccurred = false;
if (headerBuf == null) {
/* hit EOF */
@@ -307,6 +309,7 @@
try {
currEntry = new TarArchiveEntry(headerBuf, zipEncoding);
} catch (final IllegalArgumentException e) {
+ headerErrorOccurred = true;
throw new InvalidTarHeaderException(e);
}