summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Meyering2012-10-04 13:09:52 +0200
committerAnthony Liguori2012-10-05 14:58:37 +0200
commitae2150680190e510dcbcdfdbfb3a54369c75367f (patch)
tree7188095d39ccc4ab2e210a376b3df2e0a8dc8640
parentos-posix: avoid buffer overrun (diff)
downloadqemu-ae2150680190e510dcbcdfdbfb3a54369c75367f.tar.gz
qemu-ae2150680190e510dcbcdfdbfb3a54369c75367f.tar.xz
qemu-ae2150680190e510dcbcdfdbfb3a54369c75367f.zip
ppc: avoid buffer overrun: use pstrcpy, not strncpy
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>
-rw-r--r--target-ppc/kvm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index a31d278a5f..7f6e4e0b87 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -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;
}