diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-06-22 21:16:24 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2018-07-16 23:46:37 +0800 |
commit | d469fa3d995c8593680c2425f9c2c5a7a231bac7 (patch) | |
tree | 3ce6e12bb0bddd98bc66c1ad80ea6cc22ffe7029 /jbig2dec/jbig2_image.c | |
parent | dfa5b1b784b9c575cb9d797248e282871d24625c (diff) | |
download | ghostpdl-d469fa3d995c8593680c2425f9c2c5a7a231bac7.tar.gz |
jbig2dec: Avoid accessing bytes outside of MMR decoder line.
Previously the file Bug688080.pdf in bug 693798 e.g. has an object 668
containing a JBIG2 bitstream containing an MMR-coded region where the
width of the region is 32 pixels. At one point while decoding this
image, a0 is in the middle of the line and because of the decoded black
and white runs both a1 and a2 end up at the pixel just beyond the end
of the line. At this point jbig2dec would access the byte supposedly
containing this pixel beyond the end of the line, but that is not
allowed. Because this byte was written back unchanged no real harm was
done, but the access was still being performed, triggering software
like valgrind/ASAN that detects buffer overflows.
This commit also reverts the incorrect fix for bug 693798
introduced in commit 46d6b40803cb7a68ceb06b2f71db8cf3f384c2ee
where the allocated image buffer was simply extended by one byte,
thereby accommodating the illegal access.
Diffstat (limited to 'jbig2dec/jbig2_image.c')
-rw-r--r-- | jbig2dec/jbig2_image.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/jbig2dec/jbig2_image.c b/jbig2dec/jbig2_image.c index a7223b3c0..b8e74ff74 100644 --- a/jbig2dec/jbig2_image.c +++ b/jbig2dec/jbig2_image.c @@ -59,8 +59,7 @@ jbig2_image_new(Jbig2Ctx *ctx, uint32_t width, uint32_t height) jbig2_free(ctx->allocator, image); return NULL; } - /* Add 1 to accept runs that exceed image width and clamped to width+1 */ - image->data = jbig2_new(ctx, uint8_t, (int)check + 1); + image->data = jbig2_new(ctx, uint8_t, (int)check); if (image->data == NULL) { jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "could not allocate image data buffer! [stride(%d)*height(%d) bytes]", stride, height); jbig2_free(ctx->allocator, image); |