diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 3568e1090..4223ed26f 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -172,6 +172,7 @@ R Handerson Rami Ojares Randy Watler Raphael Pierquin +Ray Waldin Richard Evans Rick Beton Robert Anderson diff --git a/WHATSNEW b/WHATSNEW index 84a2f08ea..71542e14b 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -227,6 +227,9 @@ Fixed bugs: * failed to set user/password on some JDKs. Bugzilla report 32667 +* untar would go into infinite loop for some invalid tar files. + Bugzill report 29877 + Changes from Ant 1.6.1 to Ant 1.6.2 =================================== diff --git a/src/main/org/apache/tools/tar/TarBuffer.java b/src/main/org/apache/tools/tar/TarBuffer.java index 694a4870d..422d184ca 100644 --- a/src/main/org/apache/tools/tar/TarBuffer.java +++ b/src/main/org/apache/tools/tar/TarBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000,2002,2004 The Apache Software Foundation + * Copyright 2000,2002,2004-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ package org.apache.tools.tar; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; +import java.util.Arrays; /** * The TarBuffer class implements the tar archive concept @@ -231,6 +232,14 @@ public class TarBuffer { // Thanks to 'Yohann.Roussel@alcatel.fr' for this fix. // if (numBytes == -1) { + // However, just leaving the unread portion of the buffer dirty does + // cause problems in some cases. This problem is described in + // http://issues.apache.org/bugzilla/show_bug.cgi?id=29877 + // + // The solution is to fill the unused portion of the buffer with zeros. + + Arrays.fill(blockBuffer, offset, offset + bytesNeeded, (byte) 0); + break; }