ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 15230] New: - TAR long path names (GNU format) append a trailing 0 char
Date Tue, 10 Dec 2002 12:52:49 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15230>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15230

TAR long path names (GNU format) append a trailing 0 char

           Summary: TAR long path names (GNU format) append a trailing 0
                    char
           Product: Ant
           Version: 1.5.1
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core tasks
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: jdb@getsu.com


Round-tripping a long path name (in GNU format) with ant's tar and untar tasks
appends a trailing 0 char (i.e., null char) to the TarEntry's name. 
TarOutputStream adds the extra 0 char, but TarInputStream and TarEntry do not
remove it.  I don't know which side is wrong, but they are definitely not
consistent.

Someone mentioned this on the developer's list in the first half of this year,
specifically questioning the write(0) call in TarOutputStream.

Impact:
I don't see the trailing 0 char in the filesystem.  But, it is getting into
ant's XML log (via the Untar task), which breaks subsequent XML parsers.

Sample code:
This JUnit test fails on the last assertEquals(), showing the round-tripped name
with the (unprintable) char 0 appended.

import java.io.*;
import junit.framework.TestCase;
import org.apache.tools.tar.*;

public class TarRoundTripTest extends TestCase {

	private static final String LONG_NAME
		= "this/path/name/contains/more/than/one/hundred/characters/in/order/"
			+ "to/test/the/GNU/long/file/name/capability/round/tripped";

	public TarRoundTripTest(String name) {
		super(name);
	}

	/**
	 * test round-tripping long (GNU) entries
	 */
	public void testLongRoundTripping() throws IOException {
		TarEntry original = new TarEntry( LONG_NAME );
		assertEquals( "over 100 chars", true, LONG_NAME.length() > 100 );
		assertEquals( "original name", LONG_NAME, original.getName() );

		
		ByteArrayOutputStream buff = new ByteArrayOutputStream();
		TarOutputStream tos = new TarOutputStream( buff );
		tos.setLongFileMode( TarOutputStream.LONGFILE_GNU );
		tos.putNextEntry( original );
		tos.closeEntry();
		tos.close();
		
		TarInputStream tis = new TarInputStream( new ByteArrayInputStream(
buff.toByteArray() ) );
		TarEntry tripped = tis.getNextEntry();
		assertEquals( "round-tripped name", LONG_NAME, tripped.getName() );
		assertNull( "no more entries", tis.getNextEntry() );
		tis.close();
	}
}

Tested environments:
Sun JDK 1.4.1 & 1.3.1
Ant 1.5.1 & 1.4.1
Linux 2.4.7 (RedHat 7.2)

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message