MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / unz64local_CheckCurrentFileCoherencyHeader

Function unz64local_CheckCurrentFileCoherencyHeader

extlibs/minizip/src/unzip.c:1377–1458  ·  view source on GitHub ↗

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) */

Source from the content-addressed store, hash-verified

1375 (filename and size of extra field data)
1376*/
1377local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* piSizeVar,
1378 ZPOS64_T* poffset_local_extrafield,
1379 uInt* psize_local_extrafield)
1380{
1381 uLong uMagic, uData, uFlags;
1382 uLong size_filename;
1383 uLong size_extra_field;
1384 int err = UNZ_OK;
1385
1386 *piSizeVar = 0;
1387 *poffset_local_extrafield = 0;
1388 *psize_local_extrafield = 0;
1389
1390 if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
1391 s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET) != 0)
1392 return UNZ_ERRNO;
1393
1394
1395 if (err == UNZ_OK)
1396 {
1397 if (unz64local_getLong(&s->z_filefunc, s->filestream, &uMagic) != UNZ_OK)
1398 err = UNZ_ERRNO;
1399 else if (uMagic != 0x04034b50)
1400 err = UNZ_BADZIPFILE;
1401 }
1402
1403 if (unz64local_getShort(&s->z_filefunc, s->filestream, &uData) != UNZ_OK)
1404 err = UNZ_ERRNO;
1405 /*
1406 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
1407 err=UNZ_BADZIPFILE;
1408 */
1409 if (unz64local_getShort(&s->z_filefunc, s->filestream, &uFlags) != UNZ_OK)
1410 err = UNZ_ERRNO;
1411
1412 if (unz64local_getShort(&s->z_filefunc, s->filestream, &uData) != UNZ_OK)
1413 err = UNZ_ERRNO;
1414 else if ((err == UNZ_OK) && (uData != s->cur_file_info.compression_method))
1415 err = UNZ_BADZIPFILE;
1416
1417 if ((err == UNZ_OK) && (s->cur_file_info.compression_method != 0) &&
1418 /* #ifdef HAVE_BZIP2 */
1419 (s->cur_file_info.compression_method != Z_BZIP2ED) &&
1420 /* #endif */
1421 (s->cur_file_info.compression_method != Z_DEFLATED))
1422 err = UNZ_BADZIPFILE;
1423
1424 if (unz64local_getLong(&s->z_filefunc, s->filestream, &uData) != UNZ_OK) /* date/time */
1425 err = UNZ_ERRNO;
1426
1427 if (unz64local_getLong(&s->z_filefunc, s->filestream, &uData) != UNZ_OK) /* crc */
1428 err = UNZ_ERRNO;
1429 else if ((err == UNZ_OK) && (uData != s->cur_file_info.crc) && ((uFlags & 8) == 0))
1430 err = UNZ_BADZIPFILE;
1431
1432 if (unz64local_getLong(&s->z_filefunc, s->filestream, &uData) != UNZ_OK) /* size compr */
1433 err = UNZ_ERRNO;
1434 else if (uData != 0xFFFFFFFF && (err == UNZ_OK) && (uData != s->cur_file_info.compressed_size) && ((uFlags & 8) == 0))

Callers 1

unzOpenCurrentFile3Function · 0.85

Calls 2

unz64local_getLongFunction · 0.85
unz64local_getShortFunction · 0.85

Tested by

no test coverage detected