You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the user creating an archive has a UID greater than or equal to 1000000 (i.e. 7 characters instead of 6), the archive builder writes all 7 characters instead of limiting it to 6. This creates an invalid archive header which can no longer be read. This issue is also present for GID and other header fields where the actual size of the field is not checked before writing out the header data.
GNU ar version 2.40-14.fc39 only uses the first 6 digits of the UID, and drops the rest. Basically any strategy that doesn't break the headers is probably acceptable.
This bug was discovered building https://github.com/lichess-org/fishnet and wondering why it was throwing a:
Custom { kind: InvalidData, error: "Invalid file size field in entry header (" 454552 ")" }
error. #10 gave me the first hint it might be a rust-ar thing.
Code used for testing is as follows (mostly borrwed from the documentation):
use std::fs::File;
use ar::{Builder,Archive};
fn main() {
{
// Create a new archive that will be written to foo.a:
let mut builder = Builder::new(File::create("foo.a").unwrap());
// Add foo/bar.txt to the archive, under the name "bar.txt":
builder.append_path("bar.txt").unwrap();
}
let mut testarchive = Archive::new(File::open("foo.a").unwrap());
while let Some(entry) = testarchive.next_entry() {
entry.unwrap();
}
}
The text was updated successfully, but these errors were encountered:
Whoops, good find. My gut inclination would be to use UID mod 1000000, but it's probably better to just match whatever GNU ar does (or any other major implementation).
If the user creating an archive has a UID greater than or equal to 1000000 (i.e. 7 characters instead of 6), the archive builder writes all 7 characters instead of limiting it to 6. This creates an invalid archive header which can no longer be read. This issue is also present for GID and other header fields where the actual size of the field is not checked before writing out the header data.
GNU ar version 2.40-14.fc39 only uses the first 6 digits of the UID, and drops the rest. Basically any strategy that doesn't break the headers is probably acceptable.
This bug was discovered building https://github.com/lichess-org/fishnet and wondering why it was throwing a:
Custom { kind: InvalidData, error: "Invalid file size field in entry header (" 454552 ")" }
error. #10 gave me the first hint it might be a rust-ar thing.
Code used for testing is as follows (mostly borrwed from the documentation):
The text was updated successfully, but these errors were encountered: