diff options
| author | Thorsten Blum <[email protected]> | 2025-03-02 22:56:41 +0000 |
|---|---|---|
| committer | Martin K. Petersen <[email protected]> | 2025-03-04 03:11:48 +0000 |
| commit | dfb7df1ddb29c89662e84b2c82c1ff7943358ae0 (patch) | |
| tree | 80ce668d3fa267acd1dbe2c44b1d6083ec9e77b2 /net/unix/sysctl_net_unix.c | |
| parent | scsi: logging: Fix scsi_logging_level bounds (diff) | |
| download | kernel-dfb7df1ddb29c89662e84b2c82c1ff7943358ae0.tar.gz kernel-dfb7df1ddb29c89662e84b2c82c1ff7943358ae0.zip | |
scsi: target: Replace deprecated strncpy() with strscpy()
strncpy() is deprecated for NUL-terminated destination buffers; use
strscpy() instead. The destination buffer db_root is only used with "%s"
format strings and must therefore be NUL-terminated, but not NUL-padded.
Use scnprintf() because snprintf() could return a value >= DB_ROOT_LEN
and lead to an out-of-bounds access. This doesn't happen because count
is explicitly checked against DB_ROOT_LEN before. However, scnprintf()
always returns the number of characters actually written to the string
buffer, which is always within the bounds of db_root_stage, and should
be preferred over snprintf().
The size parameter of strscpy() is optional and since DB_ROOT_LEN is the
size of the destination buffer, it can be removed. Remove it to simplify
the code.
Compile-tested only.
Link: https://github.com/KSPP/linux/issues/90
Link: https://github.com/KSPP/linux/issues/105
Cc: [email protected]
Signed-off-by: Thorsten Blum <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Kees Cook <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
Diffstat (limited to 'net/unix/sysctl_net_unix.c')
0 files changed, 0 insertions, 0 deletions
