handle short files more robustly

This commit is contained in:
Bill Currie 2003-04-10 16:11:09 +00:00
parent 7052a6f20b
commit 39886ebb18

View file

@ -156,9 +156,11 @@ check_file (int fd, int offs, int len, int *zip)
lseek (fd, 0, SEEK_SET); lseek (fd, 0, SEEK_SET);
} }
if (*zip) { if (*zip) {
int r;
lseek (fd, offs, SEEK_SET); lseek (fd, offs, SEEK_SET);
read (fd, id, 2); r = read (fd, id, 2);
if (id[0] == 0x1f && id[1] == 0x8b) { if (r == 2 && id[0] == 0x1f && id[1] == 0x8b && len >= 6) {
lseek (fd, offs + len - 4, SEEK_SET); lseek (fd, offs + len - 4, SEEK_SET);
read (fd, len_bytes, 4); read (fd, len_bytes, 4);
len = ((len_bytes[3] << 24) len = ((len_bytes[3] << 24)