Messages in this thread Patch in this message | | | From | cgel.zte@gmail ... | Subject | [PATCH linux-next] perf llvm: use strscpy() is more robust and safer | Date | Thu, 22 Sep 2022 01:31:43 +0000 |
| |
From: ye xingchen <ye.xingchen@zte.com.cn>
The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL terminated strings.
Reported-by: Zeal Robot <zealci@zte.com.cn> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn> --- tools/perf/util/llvm-utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c index 2dc797007419..3e218cb8f0ae 100644 --- a/tools/perf/util/llvm-utils.c +++ b/tools/perf/util/llvm-utils.c @@ -80,7 +80,7 @@ search_program(const char *def, const char *name, if (def && def[0] != '\0') { if (def[0] == '/') { if (access(def, F_OK) == 0) { - strlcpy(output, def, PATH_MAX); + strscpy(output, def, PATH_MAX); return 0; } } else if (def[0] != '\0') @@ -99,7 +99,7 @@ search_program(const char *def, const char *name, while (path) { scnprintf(buf, sizeof(buf), "%s/%s", path, name); if (access(buf, F_OK) == 0) { - strlcpy(output, buf, PATH_MAX); + strscpy(output, buf, PATH_MAX); ret = 0; break; } -- 2.25.1
| |