fixed handling enrypted zip files

This commit is contained in:
SJ 2014-04-27 10:59:59 +02:00
parent a21f5a68e1
commit b7e61f27ef
2 changed files with 29 additions and 23 deletions

View File

@ -14,7 +14,7 @@
#define VERSION "0.1.25-master-branch" #define VERSION "0.1.25-master-branch"
#define BUILD 868 #define BUILD 869
#define HOSTID "mailarchiver" #define HOSTID "mailarchiver"

View File

@ -58,7 +58,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 && (int)sb.size > 0){ if(ZIP_EM_NONE == sb.encryption_method && 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){
@ -106,6 +106,8 @@ int unzip_file(struct session_data *sdata, struct _state *state, char *filename,
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); //printf("processing file inside the zip: %s, index: %d, size: %d\n", sb.name, sb.index, (int)sb.size);
if(ZIP_EM_NONE == sb.encryption_method) {
p = strrchr(sb.name, '.'); p = strrchr(sb.name, '.');
if((int)sb.size > 0 && 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")){
@ -133,8 +135,12 @@ int unzip_file(struct session_data *sdata, struct _state *state, char *filename,
else { else {
syslog(LOG_PRIORITY, "%s: cannot open '%s'", sdata->ttmpfile, extracted_filename); syslog(LOG_PRIORITY, "%s: cannot open '%s'", sdata->ttmpfile, extracted_filename);
} }
}
} }
else {
syslog(LOG_PRIORITY, "ERR: attachment ('%s') is in encrypted zip file", sb.name);
}
i++; i++;
} }