1 From 2deda9906480f9c8ae07b8c2a5510cc7e4c59a8e Mon Sep 17 00:00:00 2001
2 From: Alan Coopersmith <alan.coopersmith@oracle.com>
3 Date: Fri, 6 Feb 2015 15:50:45 -0800
4 Subject: [PATCH] bdfReadProperties: property count needs range check
7 Avoid integer overflow or underflow when allocating memory arrays
8 by multiplying the number of properties reported for a BDF font.
10 Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
11 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
12 Reviewed-by: Julien Cristau <jcristau@debian.org>
14 Upstream-Status: backport
16 Signed-off-by: Li Zhou <li.zhou@windriver.com>
18 src/bitmap/bdfread.c | 4 +++-
19 1 file changed, 3 insertions(+), 1 deletion(-)
21 diff --git a/src/bitmap/bdfread.c b/src/bitmap/bdfread.c
22 index 914a024..6387908 100644
23 --- a/src/bitmap/bdfread.c
24 +++ b/src/bitmap/bdfread.c
25 @@ -604,7 +604,9 @@ bdfReadProperties(FontFilePtr file, FontPtr pFont, bdfFileState *pState)
26 bdfError("missing 'STARTPROPERTIES'\n");
29 - if (sscanf((char *) line, "STARTPROPERTIES %d", &nProps) != 1) {
30 + if ((sscanf((char *) line, "STARTPROPERTIES %d", &nProps) != 1) ||
32 + (nProps > ((INT32_MAX / sizeof(FontPropRec)) - BDF_GENPROPS))) {
33 bdfError("bad 'STARTPROPERTIES'\n");