Fetch Support for tar GNUTYPE_LONGNAME chunks#17772
Fetch Support for tar GNUTYPE_LONGNAME chunks#17772dasimmet wants to merge 2 commits intoziglang:masterfrom
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.
Where is this name guaranteed? And why is this enum field not consistent with the rest?
There was a problem hiding this comment.
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.
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.
Is there a reason you don't simply read the data straight into the filename buffer?
There was a problem hiding this comment.
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.
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.
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