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

Adam Jackson ajax at redhat.com
Mon Jul 30 11:32:10 PDT 2012


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.

Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
Reviewed-by: Adam Jackson <ajax at redhat.com>
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 b1068bb..d35dcf8 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -1034,7 +1034,7 @@ KdGetOptions(InputOption **options, char *string)
 
     if (strchr(string, '=')) {
         tam_key = (strchr(string, '=') - string);
-        key = strndup(string, tam_key);
+        key = strndup(string, tam_key + 1);
         if (!key)
             goto out;
 
-- 
1.7.7.6



More information about the xorg-devel mailing list