Messages in this thread Patch in this message | | | From | cgel.zte@gmail ... | Subject | [PATCH linux-next] perf daemon: use strscpy() is more robust and safer | Date | Wed, 21 Sep 2022 09:34:27 +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/builtin-daemon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c index 6cb3f6cc36d0..1e927c4dcc81 100644 --- a/tools/perf/builtin-daemon.c +++ b/tools/perf/builtin-daemon.c @@ -606,7 +606,7 @@ static int setup_server_socket(struct daemon *daemon) memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; - strlcpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); + strscpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); unlink(path); if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) { @@ -877,7 +877,7 @@ static int setup_client_socket(struct daemon *daemon) memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; - strlcpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); + strscpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); if (connect(fd, (struct sockaddr *) &addr, sizeof(addr)) == -1) { perror("failed: connect"); -- 2.25.1
| |