|
45 | 45 | z : Bool, |
46 | 46 | ) -> (Int, Int, Int, String, Int, Int) raise FzipError { |
47 | 47 | let fnl = b2(d, b + 28) |
48 | | - // Validate filename length (max 4096 bytes is reasonable) |
49 | | - if fnl > 4096 { |
| 48 | + // Validate filename length (max `max_filename_length` bytes is reasonable) |
| 49 | + if fnl > max_filename_length { |
50 | 50 | raise fzip_err(InvalidZipData, msg="zip filename too long") |
51 | 51 | } |
52 | 52 | // Check bounds before reading filename |
@@ -143,9 +143,9 @@ fn wzh( |
143 | 143 | let mut b = b |
144 | 144 | // signature |
145 | 145 | if ce >= 0 { |
146 | | - wbytes(d, b, 0x02014B50) |
| 146 | + wbytes(d, b, zip_cd_signature.reinterpret_as_int()) |
147 | 147 | } else { |
148 | | - wbytes(d, b, 0x04034B50) |
| 148 | + wbytes(d, b, zip_local_signature.reinterpret_as_int()) |
149 | 149 | } |
150 | 150 | b += 4 |
151 | 151 | if ce >= 0 { |
@@ -221,7 +221,7 @@ fn wzh( |
221 | 221 | ///| |
222 | 222 | /// Write ZIP end of central directory record |
223 | 223 | fn wzf(o : FixedArray[Byte], b : Int, c : Int, d : Int, e : Int) -> Unit { |
224 | | - wbytes(o, b, 0x06054B50) |
| 224 | + wbytes(o, b, zip_eocd_signature.reinterpret_as_int()) |
225 | 225 | // skip disk numbers (4 bytes = 0) |
226 | 226 | wbytes(o, b + 8, c) // entries on this disk |
227 | 227 | wbytes(o, b + 10, c) // total entries |
@@ -342,7 +342,7 @@ pub fn unzip_sync( |
342 | 342 | let files : Array[(String, FixedArray[Byte])] = [] |
343 | 343 | // Find end of central directory |
344 | 344 | let mut e = data.length() - 22 |
345 | | - while e >= 0 && b4(data, e) != 0x06054B50U { |
| 345 | + while e >= 0 && b4(data, e) != zip_eocd_signature { |
346 | 346 | e -= 1 |
347 | 347 | if data.length() - e > 65558 { |
348 | 348 | raise fzip_err(InvalidZipData) |
@@ -418,7 +418,7 @@ pub fn unzip_list( |
418 | 418 | } |
419 | 419 | let infos : Array[UnzipFileInfo] = [] |
420 | 420 | let mut e = data.length() - 22 |
421 | | - while e >= 0 && b4(data, e) != 0x06054B50U { |
| 421 | + while e >= 0 && b4(data, e) != zip_eocd_signature { |
422 | 422 | e -= 1 |
423 | 423 | if data.length() - e > 65558 { |
424 | 424 | raise fzip_err(InvalidZipData) |
|
0 commit comments