summaryrefslogtreecommitdiff
path: root/cbz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2013-03-26 12:28:06 +0100
committerRobin Watts <robin.watts@artifex.com>2013-03-26 13:58:02 +0000
commit266a1a44d2f6e73878fb742e088ea722873a182e (patch)
treec35f2e6ec276e1d6edf892ea84bd227c1f51de9a /cbz
parent4d43131848c51c875e51985df5a5456f732adc09 (diff)
downloadmupdf-266a1a44d2f6e73878fb742e088ea722873a182e.tar.xz
cbz: Prevent segfault when testing for file type magic on empty files.
Diffstat (limited to 'cbz')
-rw-r--r--cbz/mucbz.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/cbz/mucbz.c b/cbz/mucbz.c
index b06851fe..874e1455 100644
--- a/cbz/mucbz.c
+++ b/cbz/mucbz.c
@@ -396,9 +396,9 @@ cbz_load_page(cbz_document *doc, int number)
data = cbz_read_zip_entry(doc, doc->entry[number].offset, &size);
- if (data[0] == 0xff && data[1] == 0xd8)
+ if (size > 2 && data[0] == 0xff && data[1] == 0xd8)
pixmap = fz_load_jpeg(ctx, data, size);
- else if (memcmp(data, "\211PNG\r\n\032\n", 8) == 0)
+ else if (size > 8 && memcmp(data, "\211PNG\r\n\032\n", 8) == 0)
pixmap = fz_load_png(ctx, data, size);
else
fz_throw(ctx, "unknown image format");