Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

archive/tar: Tar pax support for long links does not work #6056

Closed
gopherbot opened this issue Aug 6, 2013 · 6 comments
Closed

archive/tar: Tar pax support for long links does not work #6056

gopherbot opened this issue Aug 6, 2013 · 6 comments
Milestone

Comments

@gopherbot
Copy link

by marco.hennings@freiheit.com:

What steps will reproduce the problem?

1. write a new tarfile
2. add a header for a link or symlink with more than 100 characters

What is the expected output?

A pax header should be written and no error should occur

What do you see instead?

The pax header is written but it still causes an error that the header was too long.


The reason lies within the following code fragment:

    if len(hdr.Name) > fileNameSize || len(hdr.Linkname) > fileNameSize {
        var err error
        prefix, suffix, err = tw.splitUSTARLongName(hdr.Name)
        // Either we were unable to pack the long name into ustar format
        // or the link name is too long; use PAX headers.
        if err == errNameTooLong || len(hdr.Linkname) > fileNameSize {
            if err := tw.writePAXHeader(hdr); err != nil {
                return err
            } 
        } else if err != nil {
            return err
        }
    }
     [... ]
    tw.cStringw(s.next(100), hdr.Linkname, "linkname")  // linkname (157:257)

In the last line you see that the linkname is added even if it was written in the pax
header.


To solve this I have implemented missing parts of the pax header support. Attached you
find a patch. I will provide a mercurial contribution soon.

Attachments:

  1. fix-tar-pax-support.patch (13859 bytes)
@gopherbot
Copy link
Author

Comment 1 by marco.hennings@freiheit.com:

i've just noticed that the sample code i've given to describe the issue contains debug
output from me. 
It should have been:
tw.cString(s.next(100), hdr.Linkname)  // linkname (157:257)

@gopherbot
Copy link
Author

Comment 2 by marco.hennings@freiheit.com:

I've updated the patch, all test pass now and the go formatter is used.

Attachments:

  1. fix-tar-pax-support.patch (14720 bytes)

@ianlancetaylor
Copy link
Contributor

Comment 3:

Labels changed: added priority-later, removed priority-triage.

@gopherbot
Copy link
Author

Comment 4 by marco.hennings@freiheit.com:

I have posted a change according to contribution guidlines
https://golang.org/cl/12561043/

@gopherbot
Copy link
Author

Comment 5 by marco.hennings@freiheit.com:

I've updated the changeset. The pax header is not written for cases where the star
extension can be used for long numbers.

@dsymonds
Copy link
Contributor

Comment 6:

This issue was closed by revision a07c95a.

Status changed to Fixed.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants