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>
This commit is contained in:
parent
3eadc68ebd
commit
ae21506801
|
@ -795,7 +795,7 @@ static int read_cpuinfo(const char *field, char *value, int len)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!strncmp(line, field, field_len)) {
|
if (!strncmp(line, field, field_len)) {
|
||||||
strncpy(value, line, len);
|
pstrcpy(value, len, line);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue