[PATCH v2 5/7] xkb: Use memcpy for copy

Pauli Nieminen ext-pauli.nieminen at nokia.com
Wed Jul 28 12:47:05 PDT 2010


Source is not NULL terminated string so using memcpy instead of strncpy
makes more sense.

All other places doing same copy are using memcpy.

fixes:
Calling strncpy with a maximum size argument of (4) on destination
buffer "key->under.name" of size (4) can possibly leave the destination
buffer lacking null-termination

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
---

improved commit message.

 xkb/XKBGAlloc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/xkb/XKBGAlloc.c b/xkb/XKBGAlloc.c
index f9d9482..170d297 100644
--- a/xkb/XKBGAlloc.c
+++ b/xkb/XKBGAlloc.c
@@ -920,8 +920,8 @@ Bool		found;
     if ((row->num_keys>=row->sz_keys)&&(_XkbAllocOverlayKeys(row,1)!=Success))
 	return NULL;
     key= &row->keys[row->num_keys];
-    strncpy(key->under.name,under,XkbKeyNameLength);
-    strncpy(key->over.name,over,XkbKeyNameLength);
+    memcpy(key->under.name,under,XkbKeyNameLength);
+    memcpy(key->over.name,over,XkbKeyNameLength);
     row->num_keys++;
     return key;
 }
-- 
1.6.3.3



More information about the xorg-devel mailing list