Skip to content

Commit ab1c282

Browse files
tobluxchucklever
authored andcommitted
NFSD: Fix destination buffer size in nfsd4_ssc_setup_dul()
Commit 5304877 ("NFSD: Fix strncpy() fortify warning") replaced strncpy(,, sizeof(..)) with strlcpy(,, sizeof(..) - 1), but strlcpy() already guaranteed NUL-termination of the destination buffer and subtracting one byte potentially truncated the source string. The incorrect size was then carried over in commit 72f78ae ("NFSD: move from strlcpy with unused retval to strscpy") when switching from strlcpy() to strscpy(). Fix this off-by-one error by using the full size of the destination buffer again. Cc: [email protected] Fixes: 5304877 ("NFSD: Fix strncpy() fortify warning") Signed-off-by: Thorsten Blum <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 9ebcd02 commit ab1c282

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ static __be32 nfsd4_ssc_setup_dul(struct nfsd_net *nn, char *ipaddr,
15191519
return 0;
15201520
}
15211521
if (work) {
1522-
strscpy(work->nsui_ipaddr, ipaddr, sizeof(work->nsui_ipaddr) - 1);
1522+
strscpy(work->nsui_ipaddr, ipaddr, sizeof(work->nsui_ipaddr));
15231523
refcount_set(&work->nsui_refcnt, 2);
15241524
work->nsui_busy = true;
15251525
list_add_tail(&work->nsui_list, &nn->nfsd_ssc_mount_list);

0 commit comments

Comments
 (0)