Skip to content

Commit ec8ec00

Browse files
Gax-cmehmetb0
authored andcommitted
NFS: Fix potential buffer overflowin nfs_sysfs_link_rpc_client()
BugLink: https://bugs.launchpad.net/bugs/2104873 [ Upstream commit 49fd4e34751e90e6df009b70cd0659dc839e7ca8 ] name is char[64] where the size of clnt->cl_program->name remains unknown. Invoking strcat() directly will also lead to potential buffer overflow. Change them to strscpy() and strncat() to fix potential issues. Signed-off-by: Zichen Xie <[email protected]> Reviewed-by: Benjamin Coddington <[email protected]> Signed-off-by: Anna Schumaker <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Noah Wager <[email protected]> Signed-off-by: Mehmet Basaran <[email protected]>
1 parent 25374fe commit ec8ec00

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/nfs/sysfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ void nfs_sysfs_link_rpc_client(struct nfs_server *server,
280280
char name[RPC_CLIENT_NAME_SIZE];
281281
int ret;
282282

283-
strcpy(name, clnt->cl_program->name);
284-
strcat(name, uniq ? uniq : "");
285-
strcat(name, "_client");
283+
strscpy(name, clnt->cl_program->name, sizeof(name));
284+
strncat(name, uniq ? uniq : "", sizeof(name) - strlen(name) - 1);
285+
strncat(name, "_client", sizeof(name) - strlen(name) - 1);
286286

287287
ret = sysfs_create_link_nowarn(&server->kobj,
288288
&clnt->cl_sysfs->kobject, name);

0 commit comments

Comments
 (0)