added a workaround for an unzipping bug

This commit is contained in:
SJ 2012-12-04 12:01:33 +01:00
parent 06a1897970
commit 207d50ed03

View File

@ -56,7 +56,7 @@ int extract_opendocument(struct session_data *sdata, struct _state *state, char
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
while(zip_stat_index(z, i, 0, &sb) == 0){ while(zip_stat_index(z, i, 0, &sb) == 0){
if(strncmp(sb.name, prefix, strlen(prefix)) == 0){ if(strncmp(sb.name, prefix, strlen(prefix)) == 0 && (int)sb.size > 0){
zf = zip_fopen_index(z, i, 0); zf = zip_fopen_index(z, i, 0);
if(zf){ if(zf){
@ -102,9 +102,11 @@ int unzip_file(struct session_data *sdata, struct _state *state, char *filename,
if(!z) return 1; if(!z) return 1;
while(zip_stat_index(z, i, 0, &sb) == 0){ while(zip_stat_index(z, i, 0, &sb) == 0){
//printf("processing file inside the zip: %s, index: %d, size: %d\n", sb.name, sb.index, (int)sb.size);
p = strrchr(sb.name, '.'); p = strrchr(sb.name, '.');
if(p && strcmp(get_attachment_extractor_by_filename((char*)sb.name), "other")){ if((int)sb.size > 0 && p && strcmp(get_attachment_extractor_by_filename((char*)sb.name), "other")){
snprintf(extracted_filename, sizeof(extracted_filename)-1, "%s-%d-%d%s", sdata->ttmpfile, *rec, i, p); snprintf(extracted_filename, sizeof(extracted_filename)-1, "%s-%d-%d%s", sdata->ttmpfile, *rec, i, p);