Commit 59e59b1
refactor: Use FixedSizeBlock trait to serialize AesExtraField (#640)
* Apply suggested fix to src/write.rs from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
* Apply suggested fix to src/write.rs from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
* Apply suggested fix to src/write.rs from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
* Apply suggested fix to src/write.rs from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
* Apply suggested fix to src/write.rs from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
* Update src/write.rs
Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com>
Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
* Update AesMode reference in AesExtraField struct
Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
* Refactor: use FixedSizeBlock trait to serialize AesExtraField
* cargo fmt --all
* [skip ci] fix: Add repr(packed, C) to AesExtraField to fix test failures
The failing tests `write::test::fuzz_crash_2024_07_19a` and
`write::test::test_fuzz_failure_2024_05_08` were encountering
"InvalidArchive("Invalid AES encryption strength")" errors because the
`AesExtraField` struct was missing the `#[repr(packed, C)]` attribute.
Without this attribute, the struct had implicit padding between the
`aes_mode` (u8) field and the `compression_method` (u16) field, causing
the binary serialization to not match the expected ZIP AES extra field
format. This led to incorrect byte offsets when reading the aes_mode
value, resulting in invalid AES encryption strength values.
This fix ensures the struct is properly packed without padding, matching
the binary format expected by the ZIP specification.
* Fix: #[repr(packed, C)] applies to struct, not member
* Fix: needs to understand AesExtraField even without aes-crypto feature enabled
---------
Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com>1 parent 3935182 commit 59e59b1
3 files changed
Lines changed: 130 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
| 228 | + | |
| 229 | + | |
229 | 230 | | |
230 | | - | |
| 231 | + | |
231 | 232 | | |
232 | 233 | | |
233 | 234 | | |
| |||
252 | 253 | | |
253 | 254 | | |
254 | 255 | | |
255 | | - | |
| 256 | + | |
256 | 257 | | |
257 | 258 | | |
258 | 259 | | |
| |||
290 | 291 | | |
291 | 292 | | |
292 | 293 | | |
| 294 | + | |
293 | 295 | | |
294 | 296 | | |
295 | 297 | | |
| |||
321 | 323 | | |
322 | 324 | | |
323 | 325 | | |
| 326 | + | |
324 | 327 | | |
325 | 328 | | |
326 | 329 | | |
| |||
440 | 443 | | |
441 | 444 | | |
442 | 445 | | |
| 446 | + | |
443 | 447 | | |
444 | 448 | | |
445 | 449 | | |
| |||
517 | 521 | | |
518 | 522 | | |
519 | 523 | | |
| 524 | + | |
520 | 525 | | |
521 | 526 | | |
522 | 527 | | |
| |||
897 | 902 | | |
898 | 903 | | |
899 | 904 | | |
| 905 | + | |
900 | 906 | | |
901 | 907 | | |
902 | 908 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
1067 | 1067 | | |
1068 | 1068 | | |
1069 | 1069 | | |
1070 | | - | |
| 1070 | + | |
| 1071 | + | |
1071 | 1072 | | |
1072 | 1073 | | |
1073 | | - | |
| 1074 | + | |
1074 | 1075 | | |
1075 | 1076 | | |
1076 | 1077 | | |
1077 | 1078 | | |
1078 | 1079 | | |
1079 | 1080 | | |
1080 | | - | |
| 1081 | + | |
1081 | 1082 | | |
1082 | 1083 | | |
1083 | 1084 | | |
| |||
1116 | 1117 | | |
1117 | 1118 | | |
1118 | 1119 | | |
1119 | | - | |
| 1120 | + | |
| 1121 | + | |
1120 | 1122 | | |
1121 | 1123 | | |
1122 | | - | |
| 1124 | + | |
1123 | 1125 | | |
1124 | 1126 | | |
1125 | 1127 | | |
1126 | 1128 | | |
1127 | 1129 | | |
1128 | 1130 | | |
1129 | | - | |
| 1131 | + | |
1130 | 1132 | | |
1131 | 1133 | | |
1132 | 1134 | | |
| |||
1239 | 1241 | | |
1240 | 1242 | | |
1241 | 1243 | | |
1242 | | - | |
| 1244 | + | |
| 1245 | + | |
1243 | 1246 | | |
1244 | 1247 | | |
1245 | | - | |
| 1248 | + | |
1246 | 1249 | | |
1247 | 1250 | | |
1248 | 1251 | | |
1249 | 1252 | | |
1250 | 1253 | | |
1251 | 1254 | | |
1252 | | - | |
| 1255 | + | |
1253 | 1256 | | |
1254 | 1257 | | |
1255 | 1258 | | |
| |||
1268 | 1271 | | |
1269 | 1272 | | |
1270 | 1273 | | |
| 1274 | + | |
1271 | 1275 | | |
1272 | 1276 | | |
1273 | 1277 | | |
| |||
1328 | 1332 | | |
1329 | 1333 | | |
1330 | 1334 | | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
1331 | 1385 | | |
1332 | 1386 | | |
1333 | 1387 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
256 | 278 | | |
257 | 279 | | |
258 | 280 | | |
| |||
276 | 298 | | |
277 | 299 | | |
278 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
279 | 312 | | |
280 | 313 | | |
281 | 314 | | |
| |||
939 | 972 | | |
940 | 973 | | |
941 | 974 | | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
942 | 990 | | |
943 | 991 | | |
944 | 992 | | |
| |||
1302 | 1350 | | |
1303 | 1351 | | |
1304 | 1352 | | |
1305 | | - | |
1306 | | - | |
1307 | 1353 | | |
1308 | 1354 | | |
1309 | 1355 | | |
| |||
2166 | 2212 | | |
2167 | 2213 | | |
2168 | 2214 | | |
2169 | | - | |
2170 | | - | |
2171 | | - | |
2172 | | - | |
2173 | | - | |
2174 | | - | |
2175 | | - | |
2176 | | - | |
2177 | | - | |
2178 | | - | |
2179 | | - | |
2180 | | - | |
2181 | | - | |
2182 | | - | |
2183 | | - | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
2184 | 2218 | | |
| 2219 | + | |
2185 | 2220 | | |
2186 | 2221 | | |
2187 | 2222 | | |
| |||
2191 | 2226 | | |
2192 | 2227 | | |
2193 | 2228 | | |
2194 | | - | |
| 2229 | + | |
| 2230 | + | |
2195 | 2231 | | |
2196 | 2232 | | |
2197 | 2233 | | |
| |||
0 commit comments