Blame SOURCES/ghostscript-cve-2018-10194.patch

ea5d11
From 544b68a3436e72f138e283af26b168ac46dda4c5 Mon Sep 17 00:00:00 2001
ea5d11
From: Ken Sharp <ken.sharp@artifex.com>
ea5d11
Date: Wed, 18 Apr 2018 15:46:32 +0100
ea5d11
Subject: [PATCH] pdfwrite - Guard against trying to output an infinite number
ea5d11
ea5d11
Bug #699255 " Buffer overflow on pprintg1 due to mishandle postscript file data to pdf"
ea5d11
ea5d11
The file uses an enormous parameter to xyxhow, causing an overflow in
ea5d11
the calculation of text positioning (value > 1e39).
ea5d11
ea5d11
Since this is basically a nonsense value, and PostScript only supports
ea5d11
real values up to 1e38, this patch follows the same approach as for
ea5d11
a degenerate CTM, and treats it as 0.
ea5d11
ea5d11
Adobe Acrobat Distiller throws a limitcheck error, so we could do that
ea5d11
instead if this approach proves to be a problem.
ea5d11
---
ea5d11
 base/gdevpdts.c | 7 ++++++-
ea5d11
 1 file changed, 6 insertions(+), 1 deletion(-)
ea5d11
ea5d11
diff --git a/base/gdevpdts.c b/base/gdevpdts.c
ea5d11
index f9321a3..fff6c17 100644
ea5d11
--- a/base/gdevpdts.c
ea5d11
+++ b/base/gdevpdts.c
ea5d11
@@ -152,9 +152,14 @@ append_text_move(pdf_text_state_t *pts, floatp dw)
ea5d11
 static int
ea5d11
 set_text_distance(gs_point *pdist, floatp dx, floatp dy, const gs_matrix *pmat)
ea5d11
 {
ea5d11
-    int code = gs_distance_transform_inverse(dx, dy, pmat, pdist);
ea5d11
+    int code;
ea5d11
     double rounded;
ea5d11
 
ea5d11
+    if (dx > 1e38 || dy > 1e38)
ea5d11
+        code = gs_error_undefinedresult;
ea5d11
+    else
ea5d11
+        code = gs_distance_transform_inverse(dx, dy, pmat, pdist);
ea5d11
+
ea5d11
     if (code == gs_error_undefinedresult) {
ea5d11
         /* The CTM is degenerate.
ea5d11
            Can't know the distance in user space.
ea5d11
-- 
ea5d11
2.14.3
ea5d11