Skip to content

PaxExtensions fails to parse length-prefixed records when the value contains a newline #452

Description

@Park-Jiyeonn

Hi, I ran into a PAX parsing issue with a symlink whose linkpath value contains a newline.

Example:

let mut exts = tar::PaxExtensions::new(b"16 linkpath=a\nb\n");

let ext = exts.next().unwrap().unwrap();
assert_eq!(ext.key(), Ok("linkpath"));
assert_eq!(ext.value_bytes(), b"a\nb");

I expected this to parse as one PAX record, because the record is length-prefixed. But currently PaxExtensions splits the whole buffer on \n first.

From what I understand, PAX records should be parsed by consuming the decimal length prefix first.

This came up through linkpath on a symlink, but I think the same issue could affect any PAX keyword whose value contains a newline.

Would a patch that changes PaxExtensions to walk the buffer by record length be acceptable? I'd like to try it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions