]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net/9p: Replace strlen() strcpy() pair with strscpy()
authorDavid Laight <david.laight.linux@gmail.com>
Sat, 6 Jun 2026 20:27:42 +0000 (21:27 +0100)
committerDominique Martinet <asmadeus@codewreck.org>
Sun, 21 Jun 2026 05:22:57 +0000 (05:22 +0000)
Use the result of strscpy() for the overflow check.

Signed-off-by: David Laight <david.laight.linux@gmail.com>
Message-ID: <20260606202744.5113-3-david.laight.linux@gmail.com>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
net/9p/trans_fd.c

index dbad3213ba84b905d7dd4899b3e02f743a474355..eb685b52aeb26440d9e2c922f4e3ce2a69df61f7 100644 (file)
@@ -940,14 +940,12 @@ p9_fd_create_unix(struct p9_client *client, struct fs_context *fc)
        if (!addr || !strlen(addr))
                return -EINVAL;
 
-       if (strlen(addr) >= UNIX_PATH_MAX) {
+       sun_server.sun_family = PF_UNIX;
+       if (strscpy(sun_server.sun_path, addr) < 0) {
                pr_err("%s (%d): address too long: %s\n",
                       __func__, task_pid_nr(current), addr);
                return -ENAMETOOLONG;
        }
-
-       sun_server.sun_family = PF_UNIX;
-       strcpy(sun_server.sun_path, addr);
        err = __sock_create(current->nsproxy->net_ns, PF_UNIX,
                            SOCK_STREAM, 0, &csocket, 1);
        if (err < 0) {