s390/boot: Use strspcy() instead of strcpy()

Convert all strcpy() usages to strscpy(). strcpy() is deprecated since
it performs no bounds checking on the destination buffer.

Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
This commit is contained in:
Heiko Carstens 2025-04-24 11:27:09 +02:00
parent e76b8c1d7a
commit 7e7f94d106
2 changed files with 6 additions and 4 deletions

View File

@ -179,7 +179,7 @@ void setup_boot_command_line(void)
if (has_ebcdic_char(parmarea.command_line)) if (has_ebcdic_char(parmarea.command_line))
EBCASC(parmarea.command_line, COMMAND_LINE_SIZE); EBCASC(parmarea.command_line, COMMAND_LINE_SIZE);
/* copy arch command line */ /* copy arch command line */
strcpy(early_command_line, strim(parmarea.command_line)); strscpy(early_command_line, strim(parmarea.command_line));
/* append IPL PARM data to the boot command line */ /* append IPL PARM data to the boot command line */
if (!is_prot_virt_guest() && ipl_block_valid) if (!is_prot_virt_guest() && ipl_block_valid)
@ -253,7 +253,8 @@ void parse_boot_command_line(void)
int rc; int rc;
__kaslr_enabled = IS_ENABLED(CONFIG_RANDOMIZE_BASE); __kaslr_enabled = IS_ENABLED(CONFIG_RANDOMIZE_BASE);
args = strcpy(command_line_buf, early_command_line); strscpy(command_line_buf, early_command_line);
args = command_line_buf;
while (*args) { while (*args) {
args = next_arg(args, &param, &val); args = next_arg(args, &param, &val);

View File

@ -29,7 +29,8 @@ static void boot_rb_add(const char *str, size_t len)
/* store strings separated by '\0' */ /* store strings separated by '\0' */
if (len + 1 > avail) if (len + 1 > avail)
boot_rb_off = 0; boot_rb_off = 0;
strcpy(boot_rb + boot_rb_off, str); avail = sizeof(boot_rb) - boot_rb_off - 1;
strscpy(boot_rb + boot_rb_off, str, avail);
boot_rb_off += len + 1; boot_rb_off += len + 1;
} }
@ -161,7 +162,7 @@ static noinline char *strsym(char *buf, void *ip)
strscpy(buf, p, MAX_SYMLEN); strscpy(buf, p, MAX_SYMLEN);
/* reserve 15 bytes for offset/len in symbol+0x1234/0x1234 */ /* reserve 15 bytes for offset/len in symbol+0x1234/0x1234 */
p = buf + strnlen(buf, MAX_SYMLEN - 15); p = buf + strnlen(buf, MAX_SYMLEN - 15);
strcpy(p, "+0x"); strscpy(p, "+0x", MAX_SYMLEN - (p - buf));
as_hex(p + 3, off, 0); as_hex(p + 3, off, 0);
strcat(p, "/0x"); strcat(p, "/0x");
as_hex(p + strlen(p), len, 0); as_hex(p + strlen(p), len, 0);