ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 51026] New: TarEntry(File) screws up size for directory
Date Tue, 05 Apr 2011 22:46:02 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=51026

           Summary: TarEntry(File) screws up size for directory
           Product: Ant
           Version: 1.7.1
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Other
        AssignedTo: notifications@ant.apache.org
        ReportedBy: stamhankar@gmail.com


Steps to repro (written ad-hoc because the problem is very easy to describe): 

File f = new File("c:/temp");
TarEntry x = new TarEntry(f);
System.out.println(x.getSize());

Expected result:
0

Actual result:
Sometimes 0, sometimes 4096.

The reason is that File.length() behavior is undefined for directories.

Consequence: you create a tar-ball with some directory tar-entries with a size
of 4096. Then if you try to untar via TarInputStream, getNextEntry() actually
skips 4k into the buffer to get to the next entry, when really the next entry
is 0 bytes away (or something like that).

Why this doesn't affect ordinary mortals:
tar'ing something incorrectly like this is fine with GNU tar for extraction;
I'm guessing that gnu tar ignores the size field for directory tar entries.

Analogously, TarInputStream / TarEntry work fine when reading a properly
generated tar-ball because a proper tar-ball won't have the 4k size value in
tar-entries. One could argue that the fix should be in the TarEntry(File)
constructor as well as TarInputStream.getNextEntry() so that the producer
creates good tars and the consumer is tolerant of slightly bad tars.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Mime
View raw message