Messages in this thread Patch in this message | | | From | Rickard Strandqvist <> | Subject | [PATCH] tools: perf: util: svghelper.c: Cleaning up missing null-terminate in conjunction with strncpy | Date | Sun, 27 Jul 2014 00:56:02 +0200 |
| |
Ensures that the string is null-terminate in connection with the use of strncpy. And removed unnecessary magic numbers.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> --- tools/perf/util/svghelper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c index 6a0a13d..82aec8f 100644 --- a/tools/perf/util/svghelper.c +++ b/tools/perf/util/svghelper.c @@ -257,7 +257,8 @@ static char *cpu_model(void) if (file) { while (fgets(buf, 255, file)) { if (strstr(buf, "model name")) { - strncpy(cpu_m, &buf[13], 255); + strncpy(cpu_m, &buf[13], sizeof(cpu_m)); + cpu_m[sizeof(cpu_m) - 1] = '\0'; break; } } -- 1.7.10.4
| |