Skip to content

archive.extract-member passes a member name to tar without -- #639

Description

@haribo

What happens

archive.extract-member passes the member name to tar without --:

tar xzOf "$src" "$member"                      # observe
tar xzOf "$src" "$member" > "$staged"          # apply

A member whose name starts with a dash is read as options. Reproduced:

$ tar xzOf /t/a.tgz "-rf.txt"
tar: You may not specify more than one '-Acdtrux', '--delete' or '--test-label' option

$ tar xzOf /t/a.tgz -- "-rf.txt"
content

Scope, honestly

Low severity. The member has to be named -rf.txt without a ./ prefix, which tar czf … . does not produce — the archive has to come from elsewhere, or from --transform.
It is a one-token fix, and the surrounding defs already treat hostile arguments as ordinary
input (#535), so leaving this one inconsistent is the thing to correct rather than the risk
itself.

Build

-- before the member in both places. Check the other tar calls in the same file while
there: tar xzf "$src" -C "$dst" and tar tzf "$src" take no member, so they are not
affected — confirm rather than assume.

Validation

  • An adverse case extending adverse-archive.extract-member.shellf: an archive built with
    --transform so a member is named -rf.txt, extracted by name. Red before the fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugdefect or malfunction

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions