summaryrefslogtreecommitdiff
path: root/base/gxht_thresh.c
diff options
context:
space:
mode:
authorRay Johnston <ray.johnston@artifex.com>2017-07-19 22:05:33 -0700
committerRay Johnston <ray.johnston@artifex.com>2017-07-20 10:01:41 -0700
commit983e56cb679768fe5a048fbb33a43259efb9afbf (patch)
tree47c247d3a07f1820fc3fbac5f4a0cd775686b60b /base/gxht_thresh.c
parent877cbdf0b279bb4bf5f3b74182ab6d0101095f99 (diff)
downloadghostpdl-983e56cb679768fe5a048fbb33a43259efb9afbf.tar.gz
Fix Bug 696398: Segfault with fuzzing file.
Oveflow of integer caused later failure even if allocation of the ht_buffer succeeded. Detect overflow, return error.
Diffstat (limited to 'base/gxht_thresh.c')
-rw-r--r--base/gxht_thresh.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/base/gxht_thresh.c b/base/gxht_thresh.c
index 35f8e3f57..3fb840213 100644
--- a/base/gxht_thresh.c
+++ b/base/gxht_thresh.c
@@ -711,6 +711,9 @@ gxht_thresh_image_init(gx_image_enum *penum)
space */
max_height = (int) ceil(fixed2float(any_abs(penum->dst_height)) /
(float) penum->Height);
+ if ((max_height > 0) && (penum->ht_stride * spp_out > max_int / max_height))
+ return -1; /* overflow */
+
penum->ht_buffer =
gs_alloc_bytes(penum->memory,
penum->ht_stride * max_height * spp_out,