]> git.proxmox.com Git - qemu.git/commitdiff
ppc: avoid buffer overrun: use pstrcpy, not strncpy
authorJim Meyering <meyering@redhat.com>
Thu, 4 Oct 2012 11:09:52 +0000 (13:09 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 5 Oct 2012 12:58:37 +0000 (07:58 -0500)
A terminal NUL is required by caller's use of strchr.
It's better not to use strncpy at all, since there is no need
to zero out hundreds of trailing bytes for each iteration.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
target-ppc/kvm.c

index a31d278a5f4979f31892643c523b6118bd794e33..7f6e4e0b8706a3d83a1129a985f83b08500580af 100644 (file)
@@ -795,7 +795,7 @@ static int read_cpuinfo(const char *field, char *value, int len)
             break;
         }
         if (!strncmp(line, field, field_len)) {
-            strncpy(value, line, len);
+            pstrcpy(value, len, line);
             ret = 0;
             break;
         }