Remove get encoded block
This commit is contained in:
parent
a0b4fe5433
commit
e3147c10c7
3 changed files with 9 additions and 14 deletions
|
|
@ -85,19 +85,18 @@ typedef struct zip
|
||||||
char* start;
|
char* start;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
|
|
||||||
|
unsigned short entries;
|
||||||
|
|
||||||
char* cd;
|
char* cd;
|
||||||
unsigned int* lfh_off;
|
|
||||||
unsigned int entries;
|
|
||||||
EOCD* eocd;
|
EOCD* eocd;
|
||||||
|
unsigned int* lfh_off;
|
||||||
|
unsigned int* cdh_filename_length;
|
||||||
} zip;
|
} zip;
|
||||||
|
|
||||||
zip init_zip(char* data, int size);
|
zip init_zip(char* data, int size);
|
||||||
void get_eocd(zip* out);
|
void get_eocd(zip* out);
|
||||||
void get_cdh(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_bit_length_code(DHCH* dhch);
|
||||||
int get_number_dist_code(DHCH* dhch);
|
int get_number_dist_code(DHCH* dhch);
|
||||||
int get_number_litteral_code(DHCH* dhch);
|
int get_number_litteral_code(DHCH* dhch);
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,9 @@ void get_eocd(zip* z)
|
||||||
z->entries = z->eocd->number_of_entries;
|
z->entries = z->eocd->number_of_entries;
|
||||||
|
|
||||||
z->lfh_off = malloc(z->entries * sizeof(int));
|
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(
|
printf(
|
||||||
"[ERROR] Failed to allocate CDH/LFH buffer for %d entries\n",
|
"[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++)
|
for (int i = 0; i < z->eocd->number_of_entries; i++)
|
||||||
{
|
{
|
||||||
z->lfh_off[i] = cdh->off_lfh;
|
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 = (CDH*) (((char*) cdh) + sizeof(CDH) + cdh->filename_length +
|
||||||
cdh->extraf_length + cdh->file_comment_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)
|
char* decode_type1_block_vuln(bitstream* bs, char* decoded_data)
|
||||||
{
|
{
|
||||||
tree tr = build_default_tree();
|
tree tr = build_default_tree();
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,8 @@ void main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (lfh->compression_method == DEFLATE)
|
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);
|
bitstream bs = init_bitstream(data, 0 /*TODO WWEUWIEUWIEUWI*/, 0);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue