From 9244105f4b2b34c98ee6441dc150735fd4d6c24e Mon Sep 17 00:00:00 2001 From: SJ Date: Mon, 26 Jan 2015 21:34:03 +0100 Subject: [PATCH] improved zip file handling --- src/config.h | 2 +- src/extract.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/config.h b/src/config.h index ad08f43c..acd34e2f 100644 --- a/src/config.h +++ b/src/config.h @@ -14,7 +14,7 @@ #define VERSION "1.1.1" -#define BUILD 901 +#define BUILD 902 #define HOSTID "mailarchiver" diff --git a/src/extract.c b/src/extract.c index 5cb990f7..fc37ab68 100644 --- a/src/extract.c +++ b/src/extract.c @@ -52,8 +52,11 @@ int extract_opendocument(struct session_data *sdata, struct _state *state, char struct zip_stat sb; struct zip_file *zf; - z = zip_open(filename, 0, &errorp); - if(!z) return 1; + z = zip_open(filename, ZIP_CHECKCONS, &errorp); + if(!z){ + syslog(LOG_INFO, "error: invalid zip file=%s, error code=%d", filename, errorp); + return 1; + } memset(buf, 0, sizeof(buf)); @@ -100,8 +103,11 @@ int unzip_file(struct session_data *sdata, struct _state *state, char *filename, (*rec)++; - z = zip_open(filename, 0, &errorp); - if(!z) return 1; + z = zip_open(filename, ZIP_CHECKCONS, &errorp); + 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){ //printf("processing file inside the zip: %s, index: %d, size: %d\n", sb.name, sb.index, (int)sb.size);