Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf: replace strcpy() with strncpy() in util/jitdump.c

Usage of strcpy() can lead to buffer overflows. Therefore, it has been
replaced with strncpy(). The output file path is provided as a parameter
and might be restricted by command-line by default. But this defensive
patch will prevent any potential overflow, making the code more robust
against future changes in input handling.

Testing:
- ran perf test from tools/perf and did not observe any regression with
the earlier code

Signed-off-by: Hrishikesh Suresh <hrishikesh123s@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Hrishikesh Suresh and committed by
Namhyung Kim
9bef5cea 3ce77655

+2 -1
+2 -1
tools/perf/util/jitdump.c
··· 233 233 /* 234 234 * keep dirname for generating files and mmap records 235 235 */ 236 - strcpy(jd->dir, name); 236 + strncpy(jd->dir, name, PATH_MAX); 237 + jd->dir[PATH_MAX - 1] = '\0'; 237 238 dirname(jd->dir); 238 239 free(buf); 239 240