[PATCH 4/5] kinput: allocate enough space for null character.

Jeremy Huddleston jeremyhu at apple.com
Wed Oct 19 10:41:09 PDT 2011


Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

On Oct 19, 2011, at 9:01 AM, Dave Airlie wrote:

> From: Dave Airlie <airlied at redhat.com>
> 
> this code wasn't allocating enough space and was assigning the NULL
> one past the end.
> 
> Pointed out by coverity.
> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
> hw/kdrive/src/kinput.c |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
> index c14dd82..977131c 100644
> --- a/hw/kdrive/src/kinput.c
> +++ b/hw/kdrive/src/kinput.c
> @@ -1054,7 +1054,7 @@ KdGetOptions (InputOption **options, char *string)
>     if (strchr(string, '='))
>     {
>         tam_key = (strchr(string, '=') - string);
> -        newopt->key = (char *)malloc(tam_key);
> +        newopt->key = (char *)malloc(tam_key + 1);
>         strncpy(newopt->key, string, tam_key);
>         newopt->key[tam_key] = '\0';
>         newopt->value = strdup(strchr(string, '=') + 1);
> -- 
> 1.7.6.4
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 

---
Jeremy Huddleston

Rebuild Sudan
 - Board of Directors
 - http://www.rebuildsudan.org

Berkeley Foundation for Opportunities in Information Technology
 - Advisory Board
 - http://www.bfoit.org



More information about the xorg-devel mailing list