summaryrefslogtreecommitdiff
path: root/pdf
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-01-22 17:31:49 +0000
committerRobin Watts <robin.watts@artifex.com>2013-01-22 17:35:11 +0000
commitd374ec148dda5934432112245716c8a207165c6c (patch)
tree4026a3478f82176ec5413207c20f1ef754be0c78 /pdf
parent02676a60608d5669807e5731fb694d197a10c0a3 (diff)
downloadmupdf-d374ec148dda5934432112245716c8a207165c6c.tar.xz
Bug 693527: Avoid JP2K images with themselves as their SMask.
Bug 693527 points out that we fail to spot Jpeg 2000 images that have themselves as their own SMask and enter an infinite loop. We extend the code by passing the forcemask parameter in exactly the same way as the non-JPEG 2K code does. Thanks to Jarkko Poyry for spotting this, reporting it, and suggesting the fix.
Diffstat (limited to 'pdf')
-rw-r--r--pdf/pdf_image.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c
index d71d974a..a756b648 100644
--- a/pdf/pdf_image.c
+++ b/pdf/pdf_image.c
@@ -9,7 +9,7 @@ struct pdf_image_key_s {
int l2factor;
};
-static void pdf_load_jpx(pdf_document *xref, pdf_obj *dict, pdf_image *image);
+static void pdf_load_jpx(pdf_document *xref, pdf_obj *dict, pdf_image *image, int forcemask);
static void
pdf_mask_color_key(fz_pixmap *pix, int n, int *colorkey)
@@ -328,7 +328,7 @@ pdf_load_image_imp(pdf_document *xref, pdf_obj *rdb, pdf_obj *dict, fz_stream *c
/* special case for JPEG2000 images */
if (pdf_is_jpx_image(ctx, dict))
{
- pdf_load_jpx(xref, dict, image);
+ pdf_load_jpx(xref, dict, image, forcemask);
if (forcemask)
{
@@ -494,7 +494,7 @@ pdf_is_jpx_image(fz_context *ctx, pdf_obj *dict)
}
static void
-pdf_load_jpx(pdf_document *xref, pdf_obj *dict, pdf_image *image)
+pdf_load_jpx(pdf_document *xref, pdf_obj *dict, pdf_image *image, int forcemask)
{
fz_buffer *buf = NULL;
fz_colorspace *colorspace = NULL;
@@ -530,7 +530,10 @@ pdf_load_jpx(pdf_document *xref, pdf_obj *dict, pdf_image *image)
obj = pdf_dict_getsa(dict, "SMask", "Mask");
if (pdf_is_dict(obj))
{
- image->base.mask = (fz_image *)pdf_load_image_imp(xref, NULL, obj, NULL, 1);
+ if (forcemask)
+ fz_warn(ctx, "Ignoring recursive JPX soft mask");
+ else
+ image->base.mask = (fz_image *)pdf_load_image_imp(xref, NULL, obj, NULL, 1);
}
obj = pdf_dict_getsa(dict, "Decode", "D");