Skip to content

Commit ef17826

Browse files
MingcongBaiKexyBiscuit
authored andcommitted
AOSCOS: staging: sb105x: replace deprecated strlcpy() with strscpy()
The string function strlcpy() was removed in commit d262700 ("string: Remove strlcpy()") and per deprecated.rst: strlcpy() reads the entire source buffer first (since the return value is meant to match that of strlen()). This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated. The safe replacement is strscpy(), though care must be given to any cases where the return value of strlcpy() is used, since strscpy() will return negative errno values when it truncates. Replace calls to strlcpy() with strscpy(). Fixes: "AOSCOS: Revert "staging: sb105x: delete the driver"" Signed-off-by: Mingcong Bai <[email protected]> Signed-off-by: Kexy Biscuit <[email protected]>
1 parent 57fb939 commit ef17826

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/staging/sb105x/sb_pci_mp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,7 @@ static inline void mp_report_port(struct uart_driver *drv, struct sb_uart_port *
16241624
break;
16251625
default:
16261626
snprintf(address, sizeof(address),"*unknown*" );
1627-
strlcpy(address, "*unknown*", sizeof(address));
1627+
strscpy(address, "*unknown*", sizeof(address));
16281628
break;
16291629
}
16301630

0 commit comments

Comments
 (0)