zip: set minimum version field back to 4.5

I'm not sure what the deal is, it sounds like the UTF-8 bit flag is
6.3, but linux's zip utilities don't support 6.3 and do support the
bit flag, so *shrug*
This commit is contained in:
xenofem 2022-04-27 21:58:11 -04:00
parent 43cffcd54c
commit 55fa969bea

View file

@ -87,7 +87,7 @@ impl UploadedFile {
/// through "Extra field length". /// through "Extra field length".
fn shared_header_fields(&self, hash: Option<u32>) -> Vec<u8> { fn shared_header_fields(&self, hash: Option<u32>) -> Vec<u8> {
let mut fields = vec![ let mut fields = vec![
63, 0, // Minimum version required to extract: 6.3 for UTF-8 filenames 45, 0, // Minimum version required to extract: 4.5 for ZIP64
0b00001000, // General purpose bit flag: bit 3 - size and CRC-32 in data descriptor 0b00001000, // General purpose bit flag: bit 3 - size and CRC-32 in data descriptor
0b00001000, // General purpose bit flag: bit 11 - UTF-8 filenames 0b00001000, // General purpose bit flag: bit 11 - UTF-8 filenames
0, 0, // Compression method: none 0, 0, // Compression method: none
@ -138,7 +138,7 @@ impl UploadedFile {
fn central_directory_header(&self, local_header_offset: u64, hash: u32) -> Vec<u8> { fn central_directory_header(&self, local_header_offset: u64, hash: u32) -> Vec<u8> {
let mut header = vec![ let mut header = vec![
0x50, 0x4b, 0x01, 0x02, // Central directory file header signature 0x50, 0x4b, 0x01, 0x02, // Central directory file header signature
63, 3, // Made by a Unix system supporting version 6.3 45, 3, // Made by a Unix system supporting version 4.5
]; ];
header.append(&mut self.shared_header_fields(Some(hash))); header.append(&mut self.shared_header_fields(Some(hash)));
append_0(&mut header, 8); // Comment length, disk number, internal attributes, DOS external attributes append_0(&mut header, 8); // Comment length, disk number, internal attributes, DOS external attributes
@ -169,8 +169,8 @@ fn end_of_central_directory(files: &[UploadedFile]) -> Vec<u8> {
]; ];
append_0(&mut eocd, 7); // pad out the rest of the size field append_0(&mut eocd, 7); // pad out the rest of the size field
eocd.append(&mut vec![ eocd.append(&mut vec![
63, 3, // Made by a Unix system supporting version 6.3 45, 3, // Made by a Unix system supporting version 4.5
63, 0, // Minimum version 6.3 to extract 45, 0, // Minimum version 4.5 to extract
]); ]);
append_0(&mut eocd, 8); // Two 4-byte disk numbers, both 0 append_0(&mut eocd, 8); // Two 4-byte disk numbers, both 0
// Number of central directory records, on this disk and in total // Number of central directory records, on this disk and in total