ASF Bugzilla – Attachment 19770 Details for
Bug 41924
Untar target does not handle long filenames in POSIX tar files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch for this issue
patch.txt (text/plain), 2.95 KB, created by
Peter Liljenberg
on 2007-03-21 15:49:46 UTC
(
hide
)
Description:
Proposed patch for this issue
Filename:
MIME Type:
Creator:
Peter Liljenberg
Created:
2007-03-21 15:49:46 UTC
Size:
2.95 KB
patch
obsolete
>Index: /Users/peterliljenberg/Documents/workspace/AntTarPatch/src/main/org/apache/tools/tar/TarConstants.java >=================================================================== >--- /Users/peterliljenberg/Documents/workspace/AntTarPatch/src/main/org/apache/tools/tar/TarConstants.java (revision 521010) >+++ /Users/peterliljenberg/Documents/workspace/AntTarPatch/src/main/org/apache/tools/tar/TarConstants.java (working copy) >@@ -155,4 +155,12 @@ > * Identifies the *next* file on the tape as having a long name. > */ > byte LF_GNUTYPE_LONGNAME = (byte) 'L'; >+ >+ /** >+ * The byte that indicates whether the prefix is present or not >+ */ >+ int PREFIX_INDICATOR_BYTE = 345; >+ >+ int PREFIX_LEN = 155; >+ > } >Index: /Users/peterliljenberg/Documents/workspace/AntTarPatch/src/main/org/apache/tools/tar/TarEntry.java >=================================================================== >--- /Users/peterliljenberg/Documents/workspace/AntTarPatch/src/main/org/apache/tools/tar/TarEntry.java (revision 521010) >+++ /Users/peterliljenberg/Documents/workspace/AntTarPatch/src/main/org/apache/tools/tar/TarEntry.java (working copy) >@@ -609,7 +609,7 @@ > public void parseTarHeader(byte[] header) { > int offset = 0; > >- this.name = TarUtils.parseName(header, offset, NAMELEN); >+ this.name = TarUtils.parseFileName(header); > offset += NAMELEN; > this.mode = (int) TarUtils.parseOctal(header, offset, MODELEN); > offset += MODELEN; >Index: /Users/peterliljenberg/Documents/workspace/AntTarPatch/src/main/org/apache/tools/tar/TarUtils.java >=================================================================== >--- /Users/peterliljenberg/Documents/workspace/AntTarPatch/src/main/org/apache/tools/tar/TarUtils.java (revision 521026) >+++ /Users/peterliljenberg/Documents/workspace/AntTarPatch/src/main/org/apache/tools/tar/TarUtils.java (working copy) >@@ -23,6 +23,8 @@ > > package org.apache.tools.tar; > >+import org.apache.tools.tar.TarConstants; >+ > /** > * This class provides static utility methods to work with byte streams. > * >@@ -196,4 +198,32 @@ > > return sum; > } >+ >+ /** >+ * Parse a file name from a header buffer. Different from parseName >+ * since we read the "prefix" of the filename if it is present. >+ * >+ * @param header >+ * The tar entry's header buffer. >+ * >+ * @return The header's entry name. >+ */ >+ public static StringBuffer parseFileName(byte[] header) { >+ StringBuffer result = new StringBuffer(256); >+ >+ // If header[PREFIX_START] is not equal to zero, then the "prefix" is set >+ if (header[TarConstants.PREFIX_INDICATOR_BYTE] != 0) { >+ for (int i = 0; i < TarConstants.PREFIX_LEN && header[TarConstants.PREFIX_INDICATOR_BYTE + i] != 0; ++i) { >+ result.append((char) header[TarConstants.PREFIX_INDICATOR_BYTE + i]); >+ } >+ >+ result.append("/"); >+ } >+ >+ for (int i = 0; i < TarConstants.NAMELEN && header[i] != 0; ++i) { >+ result.append((char) header[i]); >+ } >+ >+ return result; >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 41924
:
19769
| 19770 |
27419