diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2014-03-08 21:05:52 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2014-04-22 19:29:04 +0100 |
commit | a384d20ff9ea220635b6c38282b73d7c33af944a (patch) | |
tree | ce44cb399b145f27319c01b928f0ab0e89b3dc58 | |
parent | bb57cfd5bebf922ad1f41c1a769eef39e4389ff6 (diff) | |
download | mupdf-a384d20ff9ea220635b6c38282b73d7c33af944a.tar.xz |
Error out on unsupported encrypted zip files
-rw-r--r-- | source/cbz/mucbz.c | 9 | ||||
-rw-r--r-- | source/xps/xps-zip.c | 10 |
2 files changed, 16 insertions, 3 deletions
diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c index dc36e0be..d0264c28 100644 --- a/source/cbz/mucbz.c +++ b/source/cbz/mucbz.c @@ -8,6 +8,8 @@ #define ZIP_CENTRAL_DIRECTORY_SIG 0x02014b50 #define ZIP_END_OF_CENTRAL_DIRECTORY_SIG 0x06054b50 +#define ZIP_ENCRYPTED_FLAG 0x1 + #define DPI 72.0f static void cbz_init_document(cbz_document *doc); @@ -76,7 +78,7 @@ cbz_read_zip_entry(cbz_document *doc, int offset, int *sizep) { fz_context *ctx = doc->ctx; fz_stream *file = doc->file; - int sig, method, namelength, extralength; + int sig, general, method, namelength, extralength; unsigned long csize, usize; unsigned char *cdata; int code; @@ -88,7 +90,10 @@ cbz_read_zip_entry(cbz_document *doc, int offset, int *sizep) fz_throw(ctx, FZ_ERROR_GENERIC, "wrong zip local file signature (0x%x)", sig); (void) getshort(doc->file); /* version */ - (void) getshort(doc->file); /* general */ + general = getshort(doc->file); /* general */ + if (general & ZIP_ENCRYPTED_FLAG) + fz_throw(doc->ctx, FZ_ERROR_GENERIC, "zipfile content is encrypted"); + method = getshort(doc->file); (void) getshort(doc->file); /* file time */ (void) getshort(doc->file); /* file date */ diff --git a/source/xps/xps-zip.c b/source/xps/xps-zip.c index da1450e3..ec0fbc90 100644 --- a/source/xps/xps-zip.c +++ b/source/xps/xps-zip.c @@ -11,6 +11,8 @@ #define ZIP64_END_OF_CENTRAL_DIRECTORY_SIG 0x06064b50 #define ZIP64_EXTRA_FIELD_SIG 0x0001 +#define ZIP_ENCRYPTED_FLAG 0x1 + static void xps_init_document(xps_document *doc); xps_part * @@ -103,6 +105,7 @@ xps_read_zip_entry(xps_document *doc, xps_entry *ent, unsigned char *outbuf) z_stream stream; unsigned char *inbuf; int sig; + int general; int method; int namelength, extralength; int code; @@ -117,7 +120,12 @@ xps_read_zip_entry(xps_document *doc, xps_entry *ent, unsigned char *outbuf) } (void) getshort(doc->file); /* version */ - (void) getshort(doc->file); /* general */ + general = getshort(doc->file); /* general */ + if (general & ZIP_ENCRYPTED_FLAG) + { + fz_throw(doc->ctx, FZ_ERROR_GENERIC, "zipfile content is encrypted"); + } + method = getshort(doc->file); (void) getshort(doc->file); /* file time */ (void) getshort(doc->file); /* file date */ |