summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2018-04-18 15:46:32 +0100
committerKen Sharp <ken.sharp@artifex.com>2018-04-18 15:46:32 +0100
commit39b1e54b2968620723bf32e96764c88797714879 (patch)
treed179b375918f24483349fce77740081eba421dce
parentfb4c58a0e097e39547dde3d46893ce1b05d19539 (diff)
pdfwrite - Guard against trying to output an infinite number
Bug #699255 " Buffer overflow on pprintg1 due to mishandle postscript file data to pdf" The file uses an enormous parameter to xyxhow, causing an overflow in the calculation of text positioning (value > 1e39). Since this is basically a nonsense value, and PostScript only supports real values up to 1e38, this patch follows the same approach as for a degenerate CTM, and treats it as 0. Adobe Acrobat Distiller throws a limitcheck error, so we could do that instead if this approach proves to be a problem.
-rw-r--r--devices/vector/gdevpdts.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/devices/vector/gdevpdts.c b/devices/vector/gdevpdts.c
index 848ad781f..172fe6bc3 100644
--- a/devices/vector/gdevpdts.c
+++ b/devices/vector/gdevpdts.c
@@ -103,9 +103,14 @@ append_text_move(pdf_text_state_t *pts, double dw)
103static int 103static int
104set_text_distance(gs_point *pdist, double dx, double dy, const gs_matrix *pmat) 104set_text_distance(gs_point *pdist, double dx, double dy, const gs_matrix *pmat)
105{ 105{
106 int code = gs_distance_transform_inverse(dx, dy, pmat, pdist); 106 int code;
107 double rounded; 107 double rounded;
108 108
109 if (dx > 1e38 || dy > 1e38)
110 code = gs_error_undefinedresult;
111 else
112 code = gs_distance_transform_inverse(dx, dy, pmat, pdist);
113
109 if (code == gs_error_undefinedresult) { 114 if (code == gs_error_undefinedresult) {
110 /* The CTM is degenerate. 115 /* The CTM is degenerate.
111 Can't know the distance in user space. 116 Can't know the distance in user space.