This commit is contained in:
atxr 2024-02-28 03:22:26 +01:00
parent 6002ddc4ad
commit 0a94e0aa5b
2 changed files with 12 additions and 8 deletions

View file

@ -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;
@ -66,6 +66,7 @@ bool scan_decoded_files(zip zip)
// 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;
}

View file

@ -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);
}