qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [4727] using strncpy is *always* a bad idea


From: Fabrice Bellard
Subject: [Qemu-devel] [4727] using strncpy is *always* a bad idea
Date: Wed, 11 Jun 2008 09:44:45 +0000

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
===================================================================
--- trunk/vl.c  2008-06-10 15:29:15 UTC (rev 4726)
+++ trunk/vl.c  2008-06-11 09:44:44 UTC (rev 4727)
@@ -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;






reply via email to

[Prev in Thread] Current Thread [Next in Thread]