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 fills devmajor and devminor fields even for non-devices #63019

Closed
NuuttiKotivuori mannequin opened this issue Aug 23, 2013 · 5 comments
Closed

tarfile fills devmajor and devminor fields even for non-devices #63019

NuuttiKotivuori mannequin opened this issue Aug 23, 2013 · 5 comments
Assignees
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@NuuttiKotivuori
Copy link
Mannequin

NuuttiKotivuori mannequin commented Aug 23, 2013

BPO 18819
Nosy @gustaebel, @ethanfurman, @wchargin
PRs
  • bpo-18819: tarfile: only set device fields for device files #18080
  • Files
  • tarfile.py.diff: patch
  • 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 = 'https://github.com/ethanfurman'
    closed_at = <Date 2020-02-14.16:03:01.387>
    created_at = <Date 2013-08-23.07:56:10.137>
    labels = ['type-bug', 'library', '3.9']
    title = 'tarfile fills devmajor and devminor fields even for non-devices'
    updated_at = <Date 2020-02-14.16:03:01.386>
    user = 'https://bugs.python.org/NuuttiKotivuori'

    bugs.python.org fields:

    activity = <Date 2020-02-14.16:03:01.386>
    actor = 'ethan.furman'
    assignee = 'ethan.furman'
    closed = True
    closed_date = <Date 2020-02-14.16:03:01.387>
    closer = 'ethan.furman'
    components = ['Library (Lib)']
    creation = <Date 2013-08-23.07:56:10.137>
    creator = 'Nuutti.Kotivuori'
    dependencies = []
    files = ['31434']
    hgrepos = []
    issue_num = 18819
    keywords = ['patch']
    message_count = 5.0
    messages = ['195949', '360327', '360441', '361202', '361911']
    nosy_count = 4.0
    nosy_names = ['lars.gustaebel', 'ethan.furman', 'Nuutti.Kotivuori', 'wchargin']
    pr_nums = ['18080']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue18819'
    versions = ['Python 3.9']

    @NuuttiKotivuori
    Copy link
    Mannequin Author

    NuuttiKotivuori mannequin commented Aug 23, 2013

    when tarfile generates a tar, it uses TarInfo objects which are packed to the binary format. This packing uses "itn" format for filling the "devmajor" and "devminor" fields of the tar file entry, with a default value of zero. The field length is 8 characters, and the formatting will format the values as octal strings, followed by a NUL byte, eg. '0000000\x00'.

    However, other common tar tools do not exhibit this behavior, instead leaving the field filled with NUL bytes in case the earlier type field does not indicate a device type. Explicitly, the value generated by other tools is then '\x00\x00\x00\x00\x00\x00\x00\x00'.

    This causes no interoperability issues (that I am aware of), but makes it hard to attempt to replicate the tar files generated by other tools exactly.

    I am attaching a simple diff fixing this, but there are probably better ways to fix this.

    @NuuttiKotivuori NuuttiKotivuori mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Aug 23, 2013
    @wchargin
    Copy link
    Mannequin

    wchargin mannequin commented Jan 20, 2020

    I've just independently run into this and sent a patch as a pull
    request. Happily, once this is fixed, the output of tarfile is
    bit-for-bit compatible with the output of GNU tar(1).

    PR: <https://github.com/python/cpython/pull/18080\>

    @wchargin wchargin mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes labels Jan 20, 2020
    @ned-deily ned-deily removed 3.7 (EOL) end of life 3.8 only security fixes labels Jan 20, 2020
    @ethanfurman
    Copy link
    Member

    Thanks for moving this issue forward, William!

    @ethanfurman ethanfurman self-assigned this Jan 22, 2020
    @wchargin
    Copy link
    Mannequin

    wchargin mannequin commented Feb 2, 2020

    My pleasure. Is there anything else that you need from me to close this
    out? It looks like the PR is approved and in an “awaiting merge” state,
    but I don’t have access to merge it.

    @ethanfurman
    Copy link
    Member

    New changeset 674935b by William Chargin in branch 'master':
    bpo-18819: tarfile: only set device fields for device files (GH-18080)
    674935b

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants