Skip to content

Commit 7e7f94d

Browse files
committed
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 <[email protected]> Signed-off-by: Heiko Carstens <[email protected]>
1 parent e76b8c1 commit 7e7f94d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

arch/s390/boot/ipl_parm.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void setup_boot_command_line(void)
179179
if (has_ebcdic_char(parmarea.command_line))
180180
EBCASC(parmarea.command_line, COMMAND_LINE_SIZE);
181181
/* copy arch command line */
182-
strcpy(early_command_line, strim(parmarea.command_line));
182+
strscpy(early_command_line, strim(parmarea.command_line));
183183

184184
/* append IPL PARM data to the boot command line */
185185
if (!is_prot_virt_guest() && ipl_block_valid)
@@ -253,7 +253,8 @@ void parse_boot_command_line(void)
253253
int rc;
254254

255255
__kaslr_enabled = IS_ENABLED(CONFIG_RANDOMIZE_BASE);
256-
args = strcpy(command_line_buf, early_command_line);
256+
strscpy(command_line_buf, early_command_line);
257+
args = command_line_buf;
257258
while (*args) {
258259
args = next_arg(args, &param, &val);
259260

arch/s390/boot/printk.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ static void boot_rb_add(const char *str, size_t len)
2929
/* store strings separated by '\0' */
3030
if (len + 1 > avail)
3131
boot_rb_off = 0;
32-
strcpy(boot_rb + boot_rb_off, str);
32+
avail = sizeof(boot_rb) - boot_rb_off - 1;
33+
strscpy(boot_rb + boot_rb_off, str, avail);
3334
boot_rb_off += len + 1;
3435
}
3536

@@ -161,7 +162,7 @@ static noinline char *strsym(char *buf, void *ip)
161162
strscpy(buf, p, MAX_SYMLEN);
162163
/* reserve 15 bytes for offset/len in symbol+0x1234/0x1234 */
163164
p = buf + strnlen(buf, MAX_SYMLEN - 15);
164-
strcpy(p, "+0x");
165+
strscpy(p, "+0x", MAX_SYMLEN - (p - buf));
165166
as_hex(p + 3, off, 0);
166167
strcat(p, "/0x");
167168
as_hex(p + strlen(p), len, 0);

0 commit comments

Comments
 (0)