Commit 151c93d
committed
validate ZIP central directory and throw on corruption
The readCentralDir() scan for the End-of-Central-Directory signature
silently fell through when it was missing, leaving the file pointer
past EOF and feeding null to unpack(). That surfaced as PHP warnings
("unpack(): Type V: not enough input") rather than a meaningful error.
Detect both the missing EOCD signature and a failed unpack() and raise
ArchiveCorruptedException instead, matching the error handling used
elsewhere in the package. Added tests covering a non-ZIP payload and
a file too short to hold an EOCD record.1 parent e45d0d9 commit 151c93d
2 files changed
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| |||
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
| 133 | + | |
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
| |||
538 | 540 | | |
539 | 541 | | |
540 | 542 | | |
| 543 | + | |
541 | 544 | | |
542 | 545 | | |
543 | 546 | | |
| |||
551 | 554 | | |
552 | 555 | | |
553 | 556 | | |
| 557 | + | |
554 | 558 | | |
555 | 559 | | |
556 | 560 | | |
557 | 561 | | |
558 | 562 | | |
| 563 | + | |
559 | 564 | | |
560 | 565 | | |
561 | 566 | | |
562 | 567 | | |
563 | 568 | | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
564 | 575 | | |
565 | 576 | | |
566 | 577 | | |
567 | 578 | | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
568 | 584 | | |
569 | 585 | | |
570 | 586 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
55 | 90 | | |
56 | 91 | | |
57 | 92 | | |
| |||
0 commit comments