improved zip file handling

This commit is contained in:
SJ 2015-01-26 21:34:03 +01:00
parent 7a3aee5bc3
commit 9244105f4b
2 changed files with 11 additions and 5 deletions

View File

@ -14,7 +14,7 @@
#define VERSION "1.1.1" #define VERSION "1.1.1"
#define BUILD 901 #define BUILD 902
#define HOSTID "mailarchiver" #define HOSTID "mailarchiver"

View File

@ -52,8 +52,11 @@ int extract_opendocument(struct session_data *sdata, struct _state *state, char
struct zip_stat sb; struct zip_stat sb;
struct zip_file *zf; struct zip_file *zf;
z = zip_open(filename, 0, &errorp); z = zip_open(filename, ZIP_CHECKCONS, &errorp);
if(!z) return 1; if(!z){
syslog(LOG_INFO, "error: invalid zip file=%s, error code=%d", filename, errorp);
return 1;
}
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
@ -100,8 +103,11 @@ int unzip_file(struct session_data *sdata, struct _state *state, char *filename,
(*rec)++; (*rec)++;
z = zip_open(filename, 0, &errorp); z = zip_open(filename, ZIP_CHECKCONS, &errorp);
if(!z) return 1; if(!z){
syslog(LOG_INFO, "error: invalid zip file=%s, error code=%d", filename, errorp);
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); //printf("processing file inside the zip: %s, index: %d, size: %d\n", sb.name, sb.index, (int)sb.size);