Track LF offsets
This commit is contained in:
parent
50293f18e0
commit
01c55375f9
2 changed files with 18 additions and 2 deletions
|
|
@ -86,6 +86,8 @@ typedef struct zip
|
||||||
char* cd;
|
char* cd;
|
||||||
CDH** cdh;
|
CDH** cdh;
|
||||||
LFH** lfh;
|
LFH** lfh;
|
||||||
|
unsigned int* lfh_off;
|
||||||
|
unsigned int entries;
|
||||||
EOCD* eocd;
|
EOCD* eocd;
|
||||||
} zip;
|
} zip;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,20 @@ void get_eocd(char* data, int size, zip* out)
|
||||||
if (strcmp(se, EOCD_SIG) == 0)
|
if (strcmp(se, EOCD_SIG) == 0)
|
||||||
{
|
{
|
||||||
out->eocd = (EOCD*) se;
|
out->eocd = (EOCD*) se;
|
||||||
out->cdh = (CDH**) malloc(out->eocd->number_of_entries * sizeof(CDH*));
|
out->entries = out->eocd->number_of_entries;
|
||||||
out->lfh = (LFH**) malloc(out->eocd->number_of_entries * sizeof(LFH*));
|
|
||||||
|
out->cdh = (CDH**) malloc(out->entries * sizeof(CDH*));
|
||||||
|
out->lfh = (LFH**) malloc(out->entries * sizeof(LFH*));
|
||||||
|
out->lfh_off = malloc(out->entries * sizeof(int));
|
||||||
|
|
||||||
|
if (!out->cdh || !out->lfh || !out->lfh_off)
|
||||||
|
{
|
||||||
|
printf(
|
||||||
|
"[ERROR] Failed to allocate CDH/LFH buffer for %d entries\n",
|
||||||
|
out->entries);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,6 +53,8 @@ void get_cdh(char* data, zip* out)
|
||||||
out->cdh[i] = cdh;
|
out->cdh[i] = cdh;
|
||||||
out->lfh[i] = (LFH*) (data + cdh->off_lfh);
|
out->lfh[i] = (LFH*) (data + cdh->off_lfh);
|
||||||
|
|
||||||
|
out->lfh_off[i] = cdh->off_lfh;
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue