mainGNU tar - Support: sr #106350, patch: large files may be...


sr #106350: patch: large files may be corrupted when added in sparse mode

Submitter:  None
Submitted:  Thu 24 Apr 2008 05:58:35 PM UTC
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  None
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup

Thu 24 Apr 2008 05:58:35 PM UTC, original submission:  

Reproducer and patch for 1.20 are attached. Edit TAR variable to point to any tar executable. Reproducer should be run in empty directory, it does the following:

Create file with the following contents:
- 1M hole
- 5000M of "A"s
- 999M hole
Tar it, untar it, and it becomes:
- 1M hole
- 4096M hole <- this is introduced by bug
- 5000-4096M of "A"s
- 999M hole

During archive creation, large block of data in sparse map is overflowing size_t numbytes element of struct sp_array and corrupted file is stored in tar archive (zero block instead of first 4Gb of data block).
Instead of changing size_t to off_t for numbytes and other variables, I thought we should better split large data blocks in pieces smaller than 4Gb. Actually, I didn't think much on changing size_t to off_t since I'm not too familiar with the code, you may prefer that way.

IMHO it's important to use 0xffffffff instead of any "portable" defines, to ensure that archive created on 64bit computer (where size_t is 8 bytes) will not have data block in sparse map bigger than 4G, and thus could be unpacked by tar on 32bit computer.

Probably tar_sparse_scan() must also be called inside conditional, I can't check this because it's not implemented/documented and I don't know what it should do.

Thank you.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #15517:  reproducer added by None (734B - application/octet-stream)
file #15518:  tar-1.20-sparse.patch added by None (639B - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by None (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2008-04-24 None Attached File- Added reproducer, #15517
        Attached File- Added tar-1.20-sparse.patch, #15518

    Back to the top

    Powered by Savane 3.13-b921.
    Corresponding source code