Patchwork libx11: Add missing NULL check

login
register
mail settings
Submitter Drew Moseley
Date July 27, 2014, 11:05 p.m.
Message ID <1406502357-17590-1-git-send-email-drew_moseley@mentor.com>
Download mbox | patch
Permalink /patch/76715/
State Accepted
Commit 062bd810fcd8c3d80689ab404766d20c9251dca6
Headers show

Comments

Drew Moseley - July 27, 2014, 11:05 p.m.
Add a check for NULL on dereferencing the xim pointer.
Using mplayer with the x11 backend will trigger this and result
in a segfault.

Signed-off-by: Drew Moseley <drew_moseley@mentor.com>
---
 .../libx11/libX11-Add-missing-NULL-check.patch     | 72 ++++++++++++++++++++++
 meta/recipes-graphics/xorg-lib/libx11_1.6.2.bb     |  1 +
 2 files changed, 73 insertions(+)
 create mode 100644 meta/recipes-graphics/xorg-lib/libx11/libX11-Add-missing-NULL-check.patch
Ross Burton - July 28, 2014, 11:51 a.m.
On 28 July 2014 00:05, Drew Moseley <drew_moseley@mentor.com> wrote:
> +Upstream-Status: Submitted [https://bugs.freedesktop.org/show_bug.cgi?id=81822]

FWIW you generally get better responses from Xorg if you mail the list
with patches.  If the patch goes nowhere then I suggest mailing the
patch to the list directly instead.

Also XOpenIM documentation says "XOpenIM returns NULL if no input
method could be opened" so arguably this should be fixed in mplayer
(and guarded in libX11).

Ross

Patch

diff --git a/meta/recipes-graphics/xorg-lib/libx11/libX11-Add-missing-NULL-check.patch b/meta/recipes-graphics/xorg-lib/libx11/libX11-Add-missing-NULL-check.patch
new file mode 100644
index 0000000..3068620
--- /dev/null
+++ b/meta/recipes-graphics/xorg-lib/libx11/libX11-Add-missing-NULL-check.patch
@@ -0,0 +1,72 @@ 
+From 4d85d5f3bd8afac893738fd88e19d8cb5cf998ff Mon Sep 17 00:00:00 2001
+From: Drew Moseley <drew_moseley@mentor.com>
+Date: Sun, 27 Jul 2014 13:10:07 -0400
+Subject: [PATCH] libX11: Add missing NULL check on im and im->methods
+
+Upstream-Status: Submitted [https://bugs.freedesktop.org/show_bug.cgi?id=81822]
+
+Signed-off-by: Drew Moseley <drew_moseley@mentor.com>
+---
+ src/xlibi18n/ICWrap.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff -ru libX11-1.6.2-orig/src/xlibi18n/ICWrap.c libX11-1.6.2/src/xlibi18n/ICWrap.c
+--- libX11-1.6.2-orig/src/xlibi18n/ICWrap.c	2014-07-27 13:38:29.586666449 -0400
++++ libX11-1.6.2/src/xlibi18n/ICWrap.c	2014-07-27 13:41:39.671609030 -0400
+@@ -169,7 +169,7 @@
+     va_list var;
+     int     total_count;
+     XIMArg *args;
+-    char   *ret;
++    char   *ret = NULL;
+ 
+     /*
+      * so count the stuff dangling here
+@@ -185,7 +185,8 @@
+     _XIMVaToNestedList(var, total_count, &args);
+     va_end(var);
+ 
+-    ret = (*im->methods->set_values) (im, args);
++    if (im && im->methods)
++	ret = (*im->methods->set_values) (im, args);
+     if (args) Xfree(args);
+     return ret;
+ }
+@@ -196,7 +197,7 @@
+     va_list var;
+     int     total_count;
+     XIMArg *args;
+-    char   *ret;
++    char   *ret = NULL;
+ 
+     /*
+      * so count the stuff dangling here
+@@ -212,7 +213,8 @@
+     _XIMVaToNestedList(var, total_count, &args);
+     va_end(var);
+ 
+-    ret = (*im->methods->get_values) (im, args);
++    if (im && im->methods)
++	ret = (*im->methods->get_values) (im, args);
+     if (args) Xfree(args);
+     return ret;
+ }
+@@ -228,7 +230,7 @@
+     va_list var;
+     int     total_count;
+     XIMArg *args;
+-    XIC     ic;
++    XIC     ic = NULL;
+ 
+     /*
+      * so count the stuff dangling here
+@@ -244,7 +246,8 @@
+     _XIMVaToNestedList(var, total_count, &args);
+     va_end(var);
+ 
+-    ic = (XIC) (*im->methods->create_ic) (im, args);
++    if (im && im->methods)
++	ic = (XIC) (*im->methods->create_ic) (im, args);
+     if (args) Xfree(args);
+     if (ic) {
+ 	ic->core.next = im->core.ic_chain;
diff --git a/meta/recipes-graphics/xorg-lib/libx11_1.6.2.bb b/meta/recipes-graphics/xorg-lib/libx11_1.6.2.bb
index 700bc36..a722648 100644
--- a/meta/recipes-graphics/xorg-lib/libx11_1.6.2.bb
+++ b/meta/recipes-graphics/xorg-lib/libx11_1.6.2.bb
@@ -5,6 +5,7 @@  BBCLASSEXTEND = "native nativesdk"
 
 SRC_URI += "file://disable_tests.patch \
             file://nls-always-use-XCOMM-instead-of-for-comments-in-Comp.patch \
+            file://libX11-Add-missing-NULL-check.patch \
            "
 
 SRC_URI[md5sum] = "c35d6ad95b06635a524579e88622fdb5"