[PATCH xinput] Fix crash for enable/disable without a device argument

Alan Coopersmith alan.coopersmith at oracle.com
Mon Nov 25 22:26:41 PST 2013


On 11/24/13 09:00 PM, Peter Hutterer wrote:
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>   src/property.c | 20 ++++++++++++++++++--
>   1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/src/property.c b/src/property.c
> index 66a3842..bf04eeb 100644
> --- a/src/property.c
> +++ b/src/property.c
> @@ -832,12 +832,28 @@ int set_prop(Display *display, int argc, char *argv[], char *name,
>
>   int disable(Display *display, int argc, char *argv[], char *name, char *desc)
>   {
> -    char *new_argv[3] = { argv[0], "Device Enabled", "0" };
> +    char *new_argv[3] = { NULL, "Device Enabled", "0" };
> +
> +    if (argc != 1) {
> +        fprintf(stderr, "Usage: xinput %s %s\n", name, desc);
> +        return EXIT_FAILURE;
> +    }
> +
> +    new_argv[0] = argv[0];
> +
>       return set_prop(display, 3, new_argv, name, desc);
>   }
>
>   int enable(Display *display, int argc, char *argv[], char *name, char *desc)
>   {
> -    char *new_argv[3] = { argv[0], "Device Enabled", "1" };
> +    char *new_argv[3] = { NULL, "Device Enabled", "1" };
> +
> +    if (argc != 1) {
> +        fprintf(stderr, "Usage: xinput %s %s\n", name, desc);
> +        return EXIT_FAILURE;
> +    }
> +
> +    new_argv[0] = argv[0];
> +
>       return set_prop(display, 3, new_argv, name, desc);
>   }
>

Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

-- 
	-Alan Coopersmith-              alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc


More information about the xorg-devel mailing list