Browse Source

fix for infinite loop on incorrect tar files

PR: 29877
Obtained from: Ray Waldin


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277329 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 20 years ago
parent
commit
322d8cef7f
3 changed files with 14 additions and 1 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +3
    -0
      WHATSNEW
  3. +10
    -1
      src/main/org/apache/tools/tar/TarBuffer.java

+ 1
- 0
CONTRIBUTORS View File

@@ -172,6 +172,7 @@ R Handerson
Rami Ojares Rami Ojares
Randy Watler Randy Watler
Raphael Pierquin Raphael Pierquin
Ray Waldin
Richard Evans Richard Evans
Rick Beton Rick Beton
Robert Anderson Robert Anderson


+ 3
- 0
WHATSNEW View File

@@ -227,6 +227,9 @@ Fixed bugs:
* <setproxy> failed to set user/password on some JDKs. * <setproxy> failed to set user/password on some JDKs.
Bugzilla report 32667 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 Changes from Ant 1.6.1 to Ant 1.6.2
=================================== ===================================




+ 10
- 1
src/main/org/apache/tools/tar/TarBuffer.java View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;


/** /**
* The TarBuffer class implements the tar archive concept * The TarBuffer class implements the tar archive concept
@@ -231,6 +232,14 @@ public class TarBuffer {
// Thanks to 'Yohann.Roussel@alcatel.fr' for this fix. // Thanks to 'Yohann.Roussel@alcatel.fr' for this fix.
// //
if (numBytes == -1) { 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; break;
} }




Loading…
Cancel
Save