mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-26 20:40:28 +00:00
Remove old zip base skew hack
Since 8ff48201ca
we no longer need the
hack where, when running .com.dbg files, we scanned for the embedded
.com file offset, and then computed zip offsets realtive to that. It
wasn't very reliable in the first place, and was causing issues with
running our new .com.dbg executables, which are true zip files.
This commit is contained in:
parent
207e18a060
commit
52d28966f7
10 changed files with 134 additions and 238 deletions
|
@ -16,12 +16,14 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/stdckdint.h"
|
||||
#include "libc/zip.internal.h"
|
||||
|
||||
/**
|
||||
* Determines if ZIP EOCD record seems legit.
|
||||
*/
|
||||
int IsZipEocd32(const uint8_t *p, size_t n, size_t i) {
|
||||
size_t offset;
|
||||
if (i > n || n - i < kZipCdirHdrMinSize) {
|
||||
return kZipErrorEocdOffsetOverflow;
|
||||
}
|
||||
|
@ -35,12 +37,15 @@ int IsZipEocd32(const uint8_t *p, size_t n, size_t i) {
|
|||
return kZipErrorEocdDiskMismatch;
|
||||
}
|
||||
if (ZIP_CDIR_RECORDSONDISK(p + i) != ZIP_CDIR_RECORDS(p + i)) {
|
||||
return kZipErrorCdirRecordsMismatch;
|
||||
return kZipErrorEocdRecordsMismatch;
|
||||
}
|
||||
if (ZIP_CDIR_RECORDS(p + i) * kZipCfileHdrMinSize > ZIP_CDIR_SIZE(p + i)) {
|
||||
return kZipErrorCdirRecordsOverflow;
|
||||
return kZipErrorEocdRecordsOverflow;
|
||||
}
|
||||
if (ZIP_CDIR_OFFSET(p + i) + ZIP_CDIR_SIZE(p + i) > i) {
|
||||
if (ckd_add(&offset, ZIP_CDIR_OFFSET(p + i), ZIP_CDIR_SIZE(p + i))) {
|
||||
return kZipErrorEocdOffsetSizeOverflow;
|
||||
}
|
||||
if (offset > i) {
|
||||
return kZipErrorCdirOffsetPastEocd;
|
||||
}
|
||||
return kZipOk;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue