[PATCH 14/15] xkb: Use memcpy for copy

Pauli Nieminen ext-pauli.nieminen at nokia.com
Tue Jul 27 05:09:55 PDT 2010


Source and destination have well defined size so use memcpy instead of
strncpy. strncpy tryes to add NULL to end of destination but it is not
possible if source doesn't have NULL.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
---
 xkb/XKBGAlloc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/xkb/XKBGAlloc.c b/xkb/XKBGAlloc.c
index 7143e7a..9a768ca 100644
--- a/xkb/XKBGAlloc.c
+++ b/xkb/XKBGAlloc.c
@@ -922,8 +922,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