Remove get encoded block

This commit is contained in:
atxr 2024-02-22 11:53:40 +01:00
parent a0b4fe5433
commit e3147c10c7
3 changed files with 9 additions and 14 deletions

View file

@ -85,19 +85,18 @@ typedef struct zip
char* start;
unsigned int size;
unsigned short entries;
char* cd;
unsigned int* lfh_off;
unsigned int entries;
EOCD* eocd;
unsigned int* lfh_off;
unsigned int* cdh_filename_length;
} zip;
zip init_zip(char* data, int size);
void get_eocd(zip* out);
void get_cdh(zip* out);
char* get_encoded_block(zip* in, int n);
void deflate(zip* in);
int get_number_bit_length_code(DHCH* dhch);
int get_number_dist_code(DHCH* dhch);
int get_number_litteral_code(DHCH* dhch);

View file

@ -29,8 +29,9 @@ void get_eocd(zip* z)
z->entries = z->eocd->number_of_entries;
z->lfh_off = malloc(z->entries * sizeof(int));
z->cdh_filename_length = malloc(z->entries * sizeof(int));
if (!z->lfh_off)
if (!z->lfh_off || !z->cdh_filename_length)
{
printf(
"[ERROR] Failed to allocate CDH/LFH buffer for %d entries\n",
@ -59,19 +60,13 @@ void get_cdh(zip* z)
for (int i = 0; i < z->eocd->number_of_entries; i++)
{
z->lfh_off[i] = cdh->off_lfh;
z->cdh_filename_length[i] = cdh->filename_length;
cdh = (CDH*) (((char*) cdh) + sizeof(CDH) + cdh->filename_length +
cdh->extraf_length + cdh->file_comment_length);
}
}
char* get_encoded_block(zip* in, int n)
{
LFH* lfh = &in->start[in->lfh_off[n]];
return in->start + in->lfh_off[n] + sizeof(LFH) + lfh->filename_length +
lfh->extraf_length;
}
char* decode_type1_block_vuln(bitstream* bs, char* decoded_data)
{
tree tr = build_default_tree();

View file

@ -46,7 +46,8 @@ void main(int argc, char** argv)
{
if (lfh->compression_method == DEFLATE)
{
char* data = get_encoded_block(&zip, k);
char* data = ((char*) lfh) + sizeof(LFH) + lfh->filename_length +
lfh->extraf_length;
bitstream bs = init_bitstream(data, 0 /*TODO WWEUWIEUWIEUWI*/, 0);