in ios/CodePush/SSZipArchive/minizip/unzip.c [962:1041]
local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s *s, uInt *piSizeVar, ZPOS64_T *poffset_local_extrafield,
uInt *psize_local_extrafield)
{
uLong uMagic, uL, uFlags;
uLong size_filename;
uLong size_extra_field;
int err = UNZ_OK;
int compression_method = 0;
*piSizeVar = 0;
*poffset_local_extrafield = 0;
*psize_local_extrafield = 0;
err = unzGoToNextDisk((unzFile)s);
if (err != UNZ_OK)
return err;
if (ZSEEK64(s->z_filefunc, s->filestream, s->cur_file_info_internal.offset_curfile +
s->cur_file_info_internal.byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET) != 0)
return UNZ_ERRNO;
if (err == UNZ_OK) {
if (unz64local_getLong(&s->z_filefunc, s->filestream, &uMagic) != UNZ_OK)
err = UNZ_ERRNO;
else if (uMagic != LOCALHEADERMAGIC)
err = UNZ_BADZIPFILE;
}
if (unz64local_getShort(&s->z_filefunc, s->filestream, &uL) != UNZ_OK)
err = UNZ_ERRNO;
if (unz64local_getShort(&s->z_filefunc, s->filestream, &uFlags) != UNZ_OK)
err = UNZ_ERRNO;
if (unz64local_getShort(&s->z_filefunc, s->filestream, &uL) != UNZ_OK)
err = UNZ_ERRNO;
else if ((err == UNZ_OK) && (uL != s->cur_file_info.compression_method))
err = UNZ_BADZIPFILE;
compression_method = (int)s->cur_file_info.compression_method;
#ifdef HAVE_AES
if (compression_method == AES_METHOD)
compression_method = (int)s->cur_file_info_internal.aes_compression_method;
#endif
if ((err == UNZ_OK) && (compression_method != 0) &&
#ifdef HAVE_BZIP2
(compression_method != Z_BZIP2ED) &&
#endif
(compression_method != Z_DEFLATED))
err = UNZ_BADZIPFILE;
if (unz64local_getLong(&s->z_filefunc, s->filestream, &uL) != UNZ_OK) /* date/time */
err = UNZ_ERRNO;
if (unz64local_getLong(&s->z_filefunc, s->filestream, &uL) != UNZ_OK) /* crc */
err = UNZ_ERRNO;
else if ((err == UNZ_OK) && (uL != s->cur_file_info.crc) && ((uFlags & 8) == 0))
err = UNZ_BADZIPFILE;
if (unz64local_getLong(&s->z_filefunc, s->filestream, &uL) != UNZ_OK) /* size compr */
err = UNZ_ERRNO;
else if ((uL != 0xffffffff) && (err == UNZ_OK) && (uL != s->cur_file_info.compressed_size) && ((uFlags & 8) == 0))
err = UNZ_BADZIPFILE;
if (unz64local_getLong(&s->z_filefunc, s->filestream, &uL) != UNZ_OK) /* size uncompr */
err = UNZ_ERRNO;
else if ((uL != 0xffffffff) && (err == UNZ_OK) && (uL != s->cur_file_info.uncompressed_size) && ((uFlags & 8) == 0))
err = UNZ_BADZIPFILE;
if (unz64local_getShort(&s->z_filefunc, s->filestream, &size_filename) != UNZ_OK)
err = UNZ_ERRNO;
else if ((err == UNZ_OK) && (size_filename != s->cur_file_info.size_filename))
err = UNZ_BADZIPFILE;
*piSizeVar += (uInt)size_filename;
if (unz64local_getShort(&s->z_filefunc, s->filestream, &size_extra_field) != UNZ_OK)
err = UNZ_ERRNO;
*poffset_local_extrafield = s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + size_filename;
*psize_local_extrafield = (uInt)size_extra_field;
*piSizeVar += (uInt)size_extra_field;
return err;
}