If the path passed to open_restricted() is null, it results in a
segfault when passing it to strneq.

Return an error code from open_restricted() when path is null.  This
leaves it up to the calling function to provide an error message.

https://bugzilla.redhat.com/show_bug.cgi?id=1536633
https://bugzilla.redhat.com/show_bug.cgi?id=1539046
https://bugzilla.redhat.com/show_bug.cgi?id=1539783
https://bugzilla.redhat.com/show_bug.cgi?id=1540662
https://bugs.freedesktop.org/show_bug.cgi?id=104278

Signed-off-by: Jeff Smith <whydo...@gmail.com>
---
 src/xf86libinput.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index 5727040..67577f4 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -2208,6 +2208,9 @@ open_restricted(const char *path, int flags, void *data)
        InputInfoPtr pInfo;
        int fd = -1;
 
+       if (path == NULL)
+               return -EFAULT;
+
        /* Special handling for sysfs files (used for pad LEDs) */
        if (strneq(path, "/sys/", 5)) {
                fd = open(path, flags);
-- 
2.14.3

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to