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

tarfile stops iteration with some longfiles #43534

Closed
faik mannequin opened this issue Jun 21, 2006 · 2 comments
Closed

tarfile stops iteration with some longfiles #43534

faik mannequin opened this issue Jun 21, 2006 · 2 comments
Labels
stdlib Python modules in the Lib dir

Comments

@faik
Copy link
Mannequin

faik mannequin commented Jun 21, 2006

BPO 1509889
Nosy @birkenfeld
Files
  • longfiles.tar: prepared tar archive for test case
  • tarfile_longfilename.patch: python-2.4.3 Lib/tarfile.py longfilename bugfix
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2006-06-21.17:47:40.000>
    created_at = <Date 2006-06-21.11:44:38.000>
    labels = ['library']
    title = 'tarfile stops iteration with some longfiles'
    updated_at = <Date 2006-06-21.17:47:40.000>
    user = 'https://bugs.python.org/faik'

    bugs.python.org fields:

    activity = <Date 2006-06-21.17:47:40.000>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2006-06-21.11:44:38.000>
    creator = 'faik'
    dependencies = []
    files = ['7341', '7342']
    hgrepos = []
    issue_num = 1509889
    keywords = ['patch']
    message_count = 2.0
    messages = ['50520', '50521']
    nosy_count = 2.0
    nosy_names = ['georg.brandl', 'faik']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1509889'
    versions = ['Python 2.4']

    @faik
    Copy link
    Mannequin Author

    faik mannequin commented Jun 21, 2006

    tarfile.py in python 2.4.3 version has a bug that makes
    it to stop iteration while reading members.

    If a file's name is longer than 100 bytes, after
    reading ././@LongLink header of the file in the tar
    archive, tarfile tries to read the actual header. But if the
    100 byte of the file's name ends with "/" and it is a
    regular file (type is a file type). Tarfile changes it's type
    to a directory by thinking that it is some old tar archive
    format's directory member (because it seems to end
    with a "/").

    I created a tar archive to test this case. You can find it
    in the attachments.

    My test code does this:

    #!/usr/bin/python
    import tarfile
    import sys
    tar = tarfile.open(sys.argv[1], "r")
    tar.list()

    If I run it with the prepared tar file, i get this output:

    faik@pardus tmp $ ./tarlist.py longfiles.tar
    -rwxr-xr-x faik/users 0 2006-06-21 13:03:59
    this.is.a.very.long.directory.name/
    -rwxr-xr-x faik/users 0 2006-06-21 13:06:17
    this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/
    -rwxr-xr-x faik/users 0 2006-06-21 13:08:21
    this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/and.this.is.another.one/
    -rw-r--r-- faik/users 19 2006-06-21 13:08:41
    this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/and.this.is.another.one/NEWS

    But if I run tar(1) with tvf options, i get this output:

    faik@pardus tmp $ tar tvf longfiles.tar
    drwxr-xr-x faik/users 0 2006-06-21 13:03:59
    this.is.a.very.long.directory.name/
    drwxr-xr-x faik/users 0 2006-06-21 13:06:17
    this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/
    drwxr-xr-x faik/users 0 2006-06-21 13:08:21
    this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/and.this.is.another.one/
    -rw-r--r-- faik/users 19 2006-06-21 13:08:41
    this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/and.this.is.another.one/NEWS
    -rw-r--r-- faik/users 18 2006-06-21 13:10:10
    this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/and.this.is.another.one/COPYING
    -rw-r--r-- faik/users 26 2006-06-21 13:09:05
    this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/and.this.is.another.one/README

    tarfile.py ends iteration with this member
    file: "this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/and.this.is.another.one/NEWS".
    Because the full directory path name length that
    contains the NEWS file is exactly 100 bytes long.

    There is also an attachment for the fix of the bug.

    @faik faik mannequin closed this as completed Jun 21, 2006
    @faik faik mannequin added the stdlib Python modules in the Lib dir label Jun 21, 2006
    @faik faik mannequin closed this as completed Jun 21, 2006
    @faik faik mannequin added the stdlib Python modules in the Lib dir label Jun 21, 2006
    @birkenfeld
    Copy link
    Member

    Logged In: YES
    user_id=849994

    This is fixed in SVN, you can try the 2.5 beta to verify it.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant