[PATCH] Fix null-pointer exception in open_restricted()
Peter Hutterer
peter.hutterer at who-t.net
Fri Feb 9 08:18:28 UTC 2018
On Fri, Feb 09, 2018 at 01:28:39AM -0600, Jeff Smith wrote:
> If the path passed to open_restricted() is null, it results in a
> segfault when passing it to strneq.
weird, but imo this really needs to (also?) be fixed in libinput, calling
open for a NULL path indicates a libinput bug. We should never call
open_restricted for something that's NULL, it stops us from having decent
error messages.
Cheers,
Peter
>
> 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 <whydoubt at 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
More information about the xorg-devel
mailing list