1 From 39b1e54b2968620723bf32e96764c88797714879 Mon Sep 17 00:00:00 2001
2 From: Ken Sharp <ken.sharp@artifex.com>
3 Date: Wed, 18 Apr 2018 15:46:32 +0100
4 Subject: [PATCH] pdfwrite - Guard against trying to output an infinite number
6 Bug #699255 " Buffer overflow on pprintg1 due to mishandle postscript file data to pdf"
8 The file uses an enormous parameter to xyxhow, causing an overflow in
9 the calculation of text positioning (value > 1e39).
11 Since this is basically a nonsense value, and PostScript only supports
12 real values up to 1e38, this patch follows the same approach as for
13 a degenerate CTM, and treats it as 0.
15 Adobe Acrobat Distiller throws a limitcheck error, so we could do that
16 instead if this approach proves to be a problem.
18 Upstream-Status: Backport
19 git://git.ghostscript.com/ghostpdl.git
21 Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
24 devices/vector/gdevpdts.c | 7 ++++++-
25 1 file changed, 6 insertions(+), 1 deletion(-)
27 diff --git a/devices/vector/gdevpdts.c b/devices/vector/gdevpdts.c
28 index 848ad78..172fe6b 100644
29 --- a/devices/vector/gdevpdts.c
30 +++ b/devices/vector/gdevpdts.c
31 @@ -103,9 +103,14 @@ append_text_move(pdf_text_state_t *pts, double dw)
33 set_text_distance(gs_point *pdist, double dx, double dy, const gs_matrix *pmat)
35 - int code = gs_distance_transform_inverse(dx, dy, pmat, pdist);
39 + if (dx > 1e38 || dy > 1e38)
40 + code = gs_error_undefinedresult;
42 + code = gs_distance_transform_inverse(dx, dy, pmat, pdist);
44 if (code == gs_error_undefinedresult) {
45 /* The CTM is degenerate.
46 Can't know the distance in user space.