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)
| 3285 | // store in *piSizeVar the size of extra info in local header |
| 3286 | // (filename and size of extra field data) |
| 3287 | int unzlocal_CheckCurrentFileCoherencyHeader (unz_s *s,uInt *piSizeVar, |
| 3288 | uLong *poffset_local_extrafield, uInt *psize_local_extrafield) |
| 3289 | { |
| 3290 | uLong uMagic,uData,uFlags; |
| 3291 | uLong size_filename; |
| 3292 | uLong size_extra_field; |
| 3293 | int err=UNZ_OK; |
| 3294 | |
| 3295 | *piSizeVar = 0; |
| 3296 | *poffset_local_extrafield = 0; |
| 3297 | *psize_local_extrafield = 0; |
| 3298 | |
| 3299 | if (lufseek(s->file,s->cur_file_info_internal.offset_curfile + s->byte_before_the_zipfile,SEEK_SET)!=0) |
| 3300 | return UNZ_ERRNO; |
| 3301 | |
| 3302 | |
| 3303 | if (err==UNZ_OK) |
| 3304 | if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) |
| 3305 | err=UNZ_ERRNO; |
| 3306 | else if (uMagic!=0x04034b50) |
| 3307 | err=UNZ_BADZIPFILE; |
| 3308 | |
| 3309 | if (unzlocal_getShort(s->file,&uData) != UNZ_OK) |
| 3310 | err=UNZ_ERRNO; |
| 3311 | // else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) |
| 3312 | // err=UNZ_BADZIPFILE; |
| 3313 | if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) |
| 3314 | err=UNZ_ERRNO; |
| 3315 | |
| 3316 | if (unzlocal_getShort(s->file,&uData) != UNZ_OK) |
| 3317 | err=UNZ_ERRNO; |
| 3318 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) |
| 3319 | err=UNZ_BADZIPFILE; |
| 3320 | |
| 3321 | if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && |
| 3322 | (s->cur_file_info.compression_method!=Z_DEFLATED)) |
| 3323 | err=UNZ_BADZIPFILE; |
| 3324 | |
| 3325 | if (unzlocal_getLong(s->file,&uData) != UNZ_OK) // date/time |
| 3326 | err=UNZ_ERRNO; |
| 3327 | |
| 3328 | if (unzlocal_getLong(s->file,&uData) != UNZ_OK) // crc |
| 3329 | err=UNZ_ERRNO; |
| 3330 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && |
| 3331 | ((uFlags & 8)==0)) |
| 3332 | err=UNZ_BADZIPFILE; |
| 3333 | |
| 3334 | if (unzlocal_getLong(s->file,&uData) != UNZ_OK) // size compr |
| 3335 | err=UNZ_ERRNO; |
| 3336 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && |
| 3337 | ((uFlags & 8)==0)) |
| 3338 | err=UNZ_BADZIPFILE; |
| 3339 | |
| 3340 | if (unzlocal_getLong(s->file,&uData) != UNZ_OK) // size uncompr |
| 3341 | err=UNZ_ERRNO; |
| 3342 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && |
| 3343 | ((uFlags & 8)==0)) |
| 3344 | err=UNZ_BADZIPFILE; |
no test coverage detected