Skip to content

Commit cfd0121

Browse files
JustinStitthcahca
authored andcommitted
s390/ipl: refactor deprecated strncpy
`strncpy` is deprecated for use on NUL-terminated destination strings [1]. Use `strscpy` which has the same behavior as `strncpy` here with the extra safeguard of guaranteeing NUL-termination of destination strings. In it's current form, this may result in silent truncation if the src string has the same size as the destination string. [hca@linux.ibm.com: use strscpy() instead of strscpy_pad()] Link: www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings[1] Link: KSPP#90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt <justinstitt@google.com> Link: https://lore.kernel.org/r/20230811-arch-s390-kernel-v1-1-7edbeeab3809@google.com Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent 979fe44 commit cfd0121

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/s390/kernel/ipl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \
266266
struct kobj_attribute *attr, \
267267
const char *buf, size_t len) \
268268
{ \
269-
strncpy(_value, buf, sizeof(_value) - 1); \
269+
strscpy(_value, buf, sizeof(_value)); \
270270
strim(_value); \
271271
return len; \
272272
} \

0 commit comments

Comments
 (0)