equal
deleted
inserted
replaced
279 jlong locpos = cenpos - ENDOFF(endbuf); |
279 jlong locpos = cenpos - ENDOFF(endbuf); |
280 char buf[4]; |
280 char buf[4]; |
281 return (cenpos >= 0 && |
281 return (cenpos >= 0 && |
282 locpos >= 0 && |
282 locpos >= 0 && |
283 readFullyAt(zip->zfd, buf, sizeof(buf), cenpos) != -1 && |
283 readFullyAt(zip->zfd, buf, sizeof(buf), cenpos) != -1 && |
284 GETSIG(buf) == CENSIG && |
284 CENSIG_AT(buf) && |
285 readFullyAt(zip->zfd, buf, sizeof(buf), locpos) != -1 && |
285 readFullyAt(zip->zfd, buf, sizeof(buf), locpos) != -1 && |
286 GETSIG(buf) == LOCSIG); |
286 LOCSIG_AT(buf)); |
287 } |
287 } |
288 |
288 |
289 /* |
289 /* |
290 * Searches for end of central directory (END) header. The contents of |
290 * Searches for end of central directory (END) header. The contents of |
291 * the END header will be read and placed in endbuf. Returns the file |
291 * the END header will be read and placed in endbuf. Returns the file |
672 } |
672 } |
673 |
673 |
674 method = CENHOW(cp); |
674 method = CENHOW(cp); |
675 nlen = CENNAM(cp); |
675 nlen = CENNAM(cp); |
676 |
676 |
677 if (GETSIG(cp) != CENSIG) |
677 if (!CENSIG_AT(cp)) |
678 ZIP_FORMAT_ERROR("invalid CEN header (bad signature)"); |
678 ZIP_FORMAT_ERROR("invalid CEN header (bad signature)"); |
679 if (CENFLG(cp) & 1) |
679 if (CENFLG(cp) & 1) |
680 ZIP_FORMAT_ERROR("invalid CEN header (encrypted entry)"); |
680 ZIP_FORMAT_ERROR("invalid CEN header (encrypted entry)"); |
681 if (method != STORED && method != DEFLATED) |
681 if (method != STORED && method != DEFLATED) |
682 ZIP_FORMAT_ERROR("invalid CEN header (bad compression method)"); |
682 ZIP_FORMAT_ERROR("invalid CEN header (bad compression method)"); |
825 return NULL; |
825 return NULL; |
826 } |
826 } |
827 |
827 |
828 // Assumption, zfd refers to start of file. Trivially, reuse errbuf. |
828 // Assumption, zfd refers to start of file. Trivially, reuse errbuf. |
829 if (readFully(zfd, errbuf, 4) != -1) { // errors will be handled later |
829 if (readFully(zfd, errbuf, 4) != -1) { // errors will be handled later |
830 if (GETSIG(errbuf) == LOCSIG) |
830 zip->locsig = LOCSIG_AT(errbuf) ? JNI_TRUE : JNI_FALSE; |
831 zip->locsig = JNI_TRUE; |
|
832 else |
|
833 zip->locsig = JNI_FALSE; |
|
834 } |
831 } |
835 |
832 |
836 len = zip->len = IO_Lseek(zfd, 0, SEEK_END); |
833 len = zip->len = IO_Lseek(zfd, 0, SEEK_END); |
837 if (len <= 0) { |
834 if (len <= 0) { |
838 if (len == 0) { /* zip file is empty */ |
835 if (len == 0) { /* zip file is empty */ |
1282 unsigned char loc[LOCHDR]; |
1279 unsigned char loc[LOCHDR]; |
1283 if (readFullyAt(zip->zfd, loc, LOCHDR, -(entry->pos)) == -1) { |
1280 if (readFullyAt(zip->zfd, loc, LOCHDR, -(entry->pos)) == -1) { |
1284 zip->msg = "error reading zip file"; |
1281 zip->msg = "error reading zip file"; |
1285 return -1; |
1282 return -1; |
1286 } |
1283 } |
1287 if (GETSIG(loc) != LOCSIG) { |
1284 if (!LOCSIG_AT(loc)) { |
1288 zip->msg = "invalid LOC header (bad signature)"; |
1285 zip->msg = "invalid LOC header (bad signature)"; |
1289 return -1; |
1286 return -1; |
1290 } |
1287 } |
1291 entry->pos = (- entry->pos) + LOCHDR + LOCNAM(loc) + LOCEXT(loc); |
1288 entry->pos = (- entry->pos) + LOCHDR + LOCNAM(loc) + LOCEXT(loc); |
1292 } |
1289 } |