Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 1 | From 0e88bee1304993668fede72498d656a2dd33a35e Mon Sep 17 00:00:00 2001 |
| 2 | From: Ken Sharp <ken.sharp@artifex.com> |
| 3 | Date: Mon, 20 Mar 2017 09:34:11 +0000 |
| 4 | Subject: [PATCH] Ensure a device has raster memory, before trying to read it. |
| 5 | |
| 6 | Bug #697676 "Null pointer dereference in mem_get_bits_rectangle()" |
| 7 | |
| 8 | This is only possible by abusing/mis-using Ghostscript-specific |
| 9 | language extensions, so cannot happen in a general PostScript program. |
| 10 | |
| 11 | Nevertheless, Ghostscript should not crash. So this commit checks the |
| 12 | memory device to see if raster memory has been allocated, before trying |
| 13 | to read from it. |
| 14 | |
| 15 | Upstream-Status: Backport |
| 16 | CVE: CVE-2017-7207 |
| 17 | |
| 18 | Author: Ken Sharp <ken.sharp@artifex.com> |
| 19 | Signed-off-by: Catalin Enache <catalin.enache@windriver.com> |
| 20 | --- |
| 21 | base/gdevmem.c | 2 ++ |
| 22 | 1 file changed, 2 insertions(+) |
| 23 | |
| 24 | diff --git a/base/gdevmem.c b/base/gdevmem.c |
| 25 | index 41108ba..183f96d 100644 |
| 26 | --- a/base/gdevmem.c |
| 27 | +++ b/base/gdevmem.c |
| 28 | @@ -605,6 +605,8 @@ mem_get_bits_rectangle(gx_device * dev, const gs_int_rect * prect, |
| 29 | GB_PACKING_CHUNKY | GB_COLORS_NATIVE | GB_ALPHA_NONE; |
| 30 | return_error(gs_error_rangecheck); |
| 31 | } |
| 32 | + if (mdev->line_ptrs == 0x00) |
| 33 | + return_error(gs_error_rangecheck); |
| 34 | if ((w <= 0) | (h <= 0)) { |
| 35 | if ((w | h) < 0) |
| 36 | return_error(gs_error_rangecheck); |
| 37 | -- |
| 38 | 2.10.2 |
| 39 | |