-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fetch Support for tar GNUTYPE_LONGNAME chunks #17772
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
Conversation
b395151 to
6105c91
Compare
6105c91 to
add2a39
Compare
| } | ||
| }, | ||
| .GNUTYPE_LONGNAME => { | ||
| assert(std.mem.eql(u8, header.name(), "././@LongLink")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this name guaranteed? And why is this enum field not consistent with the rest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name is mentioned here: https://ftp.gnu.org/old-gnu/Manuals/tar-1.12/html_node/tar_117.html
but i guess this check can be removed as the type should be enough to assume the following chunks to be a filename.
I just matched the Globals in the GNU standard. By "consistent", you mean it should be lowercased, without "GNUTYPE_", or what do you propose?
I thought it may be useful to be able to distinguish which standards the different values come from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filename seems to be nothing more than a fallback for tar implmentations that don't handle GNU fields, a longname header is identified uniquely by the type.
At the very least the enum fields should follow the style guide and be lowercase.
| assert(std.mem.eql(u8, header.name(), "././@LongLink")); | ||
|
|
||
| while (true) { | ||
| const filename_chunk = try buffer.readChunk(reader, 512); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you don't simply read the data straight into the filename buffer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'll try it, thanks. Its just what I came up with thinking not advancing the header buffer may cause issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after looking into it, one reason to do it this way could be if we barely reach MAX_PATH_BYTES, the 512 byte padding or next chunk could overflow the filename buffer.
It is highly unlikely though, as MAX_PATH_BYTES probably is always a multiple of 512, only a path with exactly MAX_PATH_BYTES will need to read another chunk from the stream to find the null terminator and overflow the buffer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unpadded length of the longname is given in the header, if it's more than MAX_PATH_BYTES, throw an error.
|
Solved instead by #18261 which included tests. |
adds gnu tar FileTypes and handle GNUTYPE_LONGNAME by reading the next chunks into the filename buffer
test case:
still missing GNUTYPE_LONGLINK support