From: Jim Meyering Date: Thu, 4 Oct 2012 11:09:52 +0000 (+0200) Subject: ppc: avoid buffer overrun: use pstrcpy, not strncpy X-Git-Tag: v1.3.0-rc0~384 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=ae2150680190e510dcbcdfdbfb3a54369c75367f;p=qemu.git 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 Signed-off-by: Anthony Liguori --- diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index a31d278a5..7f6e4e0b8 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; }