commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r760565 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
Date Tue, 31 Mar 2009 18:44:35 GMT
Author: sebb
Date: Tue Mar 31 18:44:34 2009
New Revision: 760565

URL: http://svn.apache.org/viewvc?rev=760565&view=rev
Log:
Ensure name length is correct even if one char != one byte

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java?rev=760565&r1=760564&r2=760565&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
Tue Mar 31 18:44:34 2009
@@ -176,10 +176,11 @@
                 TarArchiveEntry longLinkEntry = new TarArchiveEntry(TarConstants.GNU_LONGLINK,
                                                                     TarConstants.LF_GNUTYPE_LONGNAME);
 
-                longLinkEntry.setSize(entry.getName().length() + 1);
+                final byte[] nameBytes = entry.getName().getBytes();
+                longLinkEntry.setSize(nameBytes.length + 1); // +1 for NUL
                 putArchiveEntry(longLinkEntry);
-                write(entry.getName().getBytes());
-                write(0);
+                write(nameBytes);
+                write(0); // NUL terminator
                 closeArchiveEntry();
             } else if (longFileMode != LONGFILE_TRUNCATE) {
                 throw new RuntimeException("file name '" + entry.getName()



Mime
View raw message