* [PATCH 07/22] ppc: avoid buffer overrun: use pstrcpy, not strncpy
[not found] <1336555142-18302-2-git-send-email-jim@meyering.net>
@ 2012-05-09 9:18 ` Jim Meyering
0 siblings, 0 replies; 2+ messages in thread
From: Jim Meyering @ 2012-05-09 9:18 UTC (permalink / raw)
To: jim
Cc: Jim Meyering, Alexander Graf, Avi Kivity, Marcelo Tosatti,
open list:PowerPC, open list:Overall
From: Jim Meyering <meyering@redhat.com>
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>
---
target-ppc/kvm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index c09cc39..fb79e9f 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -587,7 +587,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;
}
--
1.7.10.1.487.ga3935e6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 07/22] ppc: avoid buffer overrun: use pstrcpy, not strncpy
[not found] <1336555446-20180-1-git-send-email-jim@meyering.net>
@ 2012-05-09 9:23 ` Jim Meyering
0 siblings, 0 replies; 2+ messages in thread
From: Jim Meyering @ 2012-05-09 9:23 UTC (permalink / raw)
To: qemu-devel
Cc: Jim Meyering, Alexander Graf, Avi Kivity, Marcelo Tosatti,
open list:PowerPC, open list:Overall
From: Jim Meyering <meyering@redhat.com>
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>
---
target-ppc/kvm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index c09cc39..fb79e9f 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -587,7 +587,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;
}
--
1.7.10.1.487.ga3935e6
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-05-09 9:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1336555446-20180-1-git-send-email-jim@meyering.net>
2012-05-09 9:23 ` [PATCH 07/22] ppc: avoid buffer overrun: use pstrcpy, not strncpy Jim Meyering
[not found] <1336555142-18302-2-git-send-email-jim@meyering.net>
2012-05-09 9:18 ` Jim Meyering
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).