diff --git a/libmineziper/src/libmineziper.c b/libmineziper/src/libmineziper.c index 5bfd886..2b27120 100644 --- a/libmineziper/src/libmineziper.c +++ b/libmineziper/src/libmineziper.c @@ -12,7 +12,7 @@ int get_uncompressed_size(zip zip) for (int i = 0; i < zip.entries; i++) { unsigned int file_size = - ((LFH*) zip.start + zip.lfh_off[i])->uncompressed_size; + ((LFH*) (zip.start + zip.lfh_off[i]))->uncompressed_size; if (size > MAX_INT / 2 && file_size > MAX_INT / 2) { @@ -32,7 +32,7 @@ bool detect_overlaps(zip zip) for (int i = 0; i < zip.entries - 1; i++) { - LFH* lfh = (LFH*) zip.start + zip.lfh_off[i]; + LFH* lfh = (LFH*) (zip.start + zip.lfh_off[i]); unsigned int lf_size = sizeof(LFH) + lfh->filename_length + lfh->extraf_length + lfh->compressed_size; @@ -60,12 +60,13 @@ bool scan_decoded_files(zip zip) if (lfh->filename_length != zip.cdh_filename_length[i]) { fprintf(stderr, "[ERROR] Mismatch in CDH/LFH filename lengths.\n"); - return true; + return true; } // Clean decoded struct and decode block if possible decoded->buffer = decoded->clean = decoded->size = 0; + // Stored block if (lfh->compression_method == COMP_NONE) { printf("[FILE %d] Scanning stored data...\n", i); @@ -87,6 +88,7 @@ bool scan_decoded_files(zip zip) memcpy(decoded->buffer, block, decoded->size); } + // Deflate compression else if (lfh->compression_method == COMP_DEFLATE) { printf("[FILE %d] Scanning first block of DEFLATED data...\n", i); @@ -180,10 +182,9 @@ bool scan_decoded_files(zip zip) { decoded->clean(decoded->buffer); } - - free(decoded); } + free(decoded); return false; } diff --git a/libmineziper/src/libmineziper_zip.c b/libmineziper/src/libmineziper_zip.c index 7d6f892..d14c290 100644 --- a/libmineziper/src/libmineziper_zip.c +++ b/libmineziper/src/libmineziper_zip.c @@ -33,7 +33,8 @@ void get_eocd(zip* z) if (!z->lfh_off || !z->cdh_filename_length) { - fprintf(stderr, + fprintf( + stderr, "[ERROR] Failed to allocate CDH/LFH buffer for %d entries\n", z->entries); exit(1); @@ -87,7 +88,8 @@ char* decode_type1_block_vuln(bitstream* bs, char* decoded_data) if ((token = next_token(bs, tr_dist)) == END_OF_BLOCK) { - fprintf(stderr, "[ERROR] Got EndOfBlock when decoding distance token\n"); + fprintf( + stderr, "[ERROR] Got EndOfBlock when decoding distance token\n"); exit(1); } @@ -127,7 +129,8 @@ char* decode_type1_block_v2( if ((token = next_token(bs, tr_dist)) == END_OF_BLOCK) { - fprintf(stderr, "[ERROR] Got EndOfBlock when decoding distance token\n"); + fprintf( + stderr, "[ERROR] Got EndOfBlock when decoding distance token\n"); exit(1); }