summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Zhou <li.zhou@windriver.com>2015-04-27 02:54:22 (GMT)
committerJoshua Lock <joshua.lock@collabora.co.uk>2015-04-28 09:07:07 (GMT)
commit582bdc0dc4c381741859016a1399d7040bffa253 (patch)
treeb20a7945d2a93d280051781c1ffab967e3590be8
parent17cfefa78f6ad44df975eaa69a8fd8b6526010f7 (diff)
downloadopenembedded-core-fido-next.tar.gz
openembedded-core-fido-next.tar.xz
libxfont: Security Advisory - libxfont - CVE-2015-1804fido-next
bdfReadCharacters: ensure metrics fit into xCharInfo struct We use 32-bit ints to read from the bdf file, but then try to stick into a 16-bit int in the xCharInfo struct, so make sure they won't overflow that range. (From OE-Core rev: 4dd4b96b6d60246338bb30ede9f3ab1b2e757be9) Signed-off-by: Li Zhou <li.zhou@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-graphics/xorg-lib/libxfont/0001-bdfReadCharacters-ensure-metrics-fit-into-xCharInfo-.patch80
-rw-r--r--meta/recipes-graphics/xorg-lib/libxfont_1.5.0.bb1
2 files changed, 81 insertions, 0 deletions
diff --git a/meta/recipes-graphics/xorg-lib/libxfont/0001-bdfReadCharacters-ensure-metrics-fit-into-xCharInfo-.patch b/meta/recipes-graphics/xorg-lib/libxfont/0001-bdfReadCharacters-ensure-metrics-fit-into-xCharInfo-.patch
new file mode 100644
index 0000000..b64f1d9
--- /dev/null
+++ b/meta/recipes-graphics/xorg-lib/libxfont/0001-bdfReadCharacters-ensure-metrics-fit-into-xCharInfo-.patch
@@ -0,0 +1,80 @@
+From 2351c83a77a478b49cba6beb2ad386835e264744 Mon Sep 17 00:00:00 2001
+From: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Fri, 6 Mar 2015 22:54:58 -0800
+Subject: [PATCH] bdfReadCharacters: ensure metrics fit into xCharInfo struct
+ [CVE-2015-1804]
+
+We use 32-bit ints to read from the bdf file, but then try to stick
+into a 16-bit int in the xCharInfo struct, so make sure they won't
+overflow that range.
+
+Found by afl-1.24b.
+
+v2: Verify that additions won't overflow 32-bit int range either.
+v3: As Julien correctly observes, the previous check for bh & bw not
+ being < 0 reduces the number of cases we need to check for overflow.
+
+Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+Reviewed-by: Julien Cristau <jcristau@debian.org>
+
+Upstream-Status: backport
+
+Signed-off-by: Li Zhou <li.zhou@windriver.com>
+---
+ src/bitmap/bdfread.c | 26 ++++++++++++++++++++++++--
+ 1 file changed, 24 insertions(+), 2 deletions(-)
+
+diff --git a/src/bitmap/bdfread.c b/src/bitmap/bdfread.c
+index 1b29b81..a0ace8f 100644
+--- a/src/bitmap/bdfread.c
++++ b/src/bitmap/bdfread.c
+@@ -62,8 +62,16 @@ from The Open Group.
+
+ #if HAVE_STDINT_H
+ #include <stdint.h>
+-#elif !defined(INT32_MAX)
+-#define INT32_MAX 0x7fffffff
++#else
++# ifndef INT32_MAX
++# define INT32_MAX 0x7fffffff
++# endif
++# ifndef INT16_MAX
++# define INT16_MAX 0x7fff
++# endif
++# ifndef INT16_MIN
++# define INT16_MIN (0 - 0x8000)
++# endif
+ #endif
+
+ #define INDICES 256
+@@ -417,6 +425,12 @@ bdfReadCharacters(FontFilePtr file, FontPtr pFont, bdfFileState *pState,
+ bdfError("DWIDTH y value must be zero\n");
+ goto BAILOUT;
+ }
++ /* xCharInfo metrics are stored as INT16 */
++ if ((wx < 0) || (wx > INT16_MAX)) {
++ bdfError("character '%s' has out of range width, %d\n",
++ charName, wx);
++ goto BAILOUT;
++ }
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if ((!line) || (sscanf((char *) line, "BBX %d %d %d %d", &bw, &bh, &bl, &bb) != 4)) {
+ bdfError("bad 'BBX'\n");
+@@ -427,6 +441,14 @@ bdfReadCharacters(FontFilePtr file, FontPtr pFont, bdfFileState *pState,
+ charName, bw, bh);
+ goto BAILOUT;
+ }
++ /* xCharInfo metrics are read as int, but stored as INT16 */
++ if ((bl > INT16_MAX) || (bl < INT16_MIN) ||
++ (bb > INT16_MAX) || (bb < INT16_MIN) ||
++ (bw > (INT16_MAX - bl)) || (bh > (INT16_MAX - bb))) {
++ bdfError("character '%s' has out of range metrics, %d %d %d %d\n",
++ charName, bl, (bl+bw), (bh+bb), -bb);
++ goto BAILOUT;
++ }
+ line = bdfGetLine(file, lineBuf, BDFLINELEN);
+ if ((line) && (bdfIsPrefix(line, "ATTRIBUTES"))) {
+ for (p = line + strlen("ATTRIBUTES ");
+--
+1.7.9.5
+
diff --git a/meta/recipes-graphics/xorg-lib/libxfont_1.5.0.bb b/meta/recipes-graphics/xorg-lib/libxfont_1.5.0.bb
index 64ec6a3..dfd2dc6 100644
--- a/meta/recipes-graphics/xorg-lib/libxfont_1.5.0.bb
+++ b/meta/recipes-graphics/xorg-lib/libxfont_1.5.0.bb
@@ -20,6 +20,7 @@ BBCLASSEXTEND = "native"
SRC_URI += "file://0001-bdfReadProperties-property-count-needs-range-check-C.patch \
file://0001-bdfReadCharacters-bailout-if-a-char-s-bitmap-cannot-.patch \
+ file://0001-bdfReadCharacters-ensure-metrics-fit-into-xCharInfo-.patch \
"
SRC_URI[md5sum] = "664629bfa7cdf8b984155019fd395dcb"