Read the local header of the current zipfile Check the coherency of the local header and info in the end of central directory about this file store in *piSizeVar the size of extra info in local header (filename and size of extra field data) */
| 1383 | (filename and size of extra field data) |
| 1384 | */ |
| 1385 | local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar, |
| 1386 | ZPOS64_T * poffset_local_extrafield, |
| 1387 | uInt * psize_local_extrafield) |
| 1388 | { |
| 1389 | uLong uMagic,uData,uFlags; |
| 1390 | uLong size_filename; |
| 1391 | uLong size_extra_field; |
| 1392 | int err=UNZ_OK; |
| 1393 | |
| 1394 | *piSizeVar = 0; |
| 1395 | *poffset_local_extrafield = 0; |
| 1396 | *psize_local_extrafield = 0; |
| 1397 | |
| 1398 | if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + |
| 1399 | s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) |
| 1400 | return UNZ_ERRNO; |
| 1401 | |
| 1402 | |
| 1403 | if (err==UNZ_OK) |
| 1404 | { |
| 1405 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) |
| 1406 | err=UNZ_ERRNO; |
| 1407 | else if (uMagic!=0x04034b50) |
| 1408 | err=UNZ_BADZIPFILE; |
| 1409 | } |
| 1410 | |
| 1411 | if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) |
| 1412 | err=UNZ_ERRNO; |
| 1413 | /* |
| 1414 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) |
| 1415 | err=UNZ_BADZIPFILE; |
| 1416 | */ |
| 1417 | if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) |
| 1418 | err=UNZ_ERRNO; |
| 1419 | |
| 1420 | if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) |
| 1421 | err=UNZ_ERRNO; |
| 1422 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) |
| 1423 | err=UNZ_BADZIPFILE; |
| 1424 | |
| 1425 | if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && |
| 1426 | /* #ifdef HAVE_BZIP2 */ |
| 1427 | (s->cur_file_info.compression_method!=Z_BZIP2ED) && |
| 1428 | /* #endif */ |
| 1429 | (s->cur_file_info.compression_method!=Z_DEFLATED)) |
| 1430 | err=UNZ_BADZIPFILE; |
| 1431 | |
| 1432 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ |
| 1433 | err=UNZ_ERRNO; |
| 1434 | |
| 1435 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ |
| 1436 | err=UNZ_ERRNO; |
| 1437 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0)) |
| 1438 | err=UNZ_BADZIPFILE; |
| 1439 | |
| 1440 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ |
| 1441 | err=UNZ_ERRNO; |
| 1442 | else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0)) |
no test coverage detected