Skip to contentSkip to conversation

[4727] using strncpy is *always* a bad idea

Qemu-devel Fabrice Bellard 1 participant 1 message Jun 11, 2008

lore
Share & tools
lore
#0 lore raw

Revision: 4727

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4727
Author:   bellard
Date:     2008-06-11 09:44:44 +0000 (Wed, 11 Jun 2008)

Log Message:
-----------
using strncpy is *always* a bad idea

Modified Paths:
--------------
trunk/vl.c

Modified: trunk/vl.c
===================================================================

vl.c +2 -3
@@ -3394,8 +3394,7 @@
 #ifndef _WIN32
 	if (is_unix) {
 	    char path[109];
-	    strncpy(path, uaddr.sun_path, 108);
-	    path[108] = 0;
+	    pstrcpy(path, sizeof(path), uaddr.sun_path);
 	    unlink(path);
 	} else
 #endif
@@ -5075,7 +5074,7 @@
     }
 
     if (get_param_value(buf, sizeof(buf), "if", str)) {
-        strncpy(devname, buf, sizeof(devname));
+        pstrcpy(devname, sizeof(devname), buf);
         if (!strcmp(buf, "ide")) {
 	    type = IF_IDE;
             max_devs = MAX_IDE_DEVS;