Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+6 -4
+3 -2
arch/s390/boot/ipl_parm.c
··· 179 179 if (has_ebcdic_char(parmarea.command_line)) 180 180 EBCASC(parmarea.command_line, COMMAND_LINE_SIZE); 181 181 /* copy arch command line */ 182 - strcpy(early_command_line, strim(parmarea.command_line)); 182 + strscpy(early_command_line, strim(parmarea.command_line)); 183 183 184 184 /* append IPL PARM data to the boot command line */ 185 185 if (!is_prot_virt_guest() && ipl_block_valid) ··· 253 253 int rc; 254 254 255 255 __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; 257 258 while (*args) { 258 259 args = next_arg(args, &param, &val); 259 260
+3 -2
arch/s390/boot/printk.c
··· 29 29 /* store strings separated by '\0' */ 30 30 if (len + 1 > avail) 31 31 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); 33 34 boot_rb_off += len + 1; 34 35 } 35 36 ··· 162 161 strscpy(buf, p, MAX_SYMLEN); 163 162 /* reserve 15 bytes for offset/len in symbol+0x1234/0x1234 */ 164 163 p = buf + strnlen(buf, MAX_SYMLEN - 15); 165 - strcpy(p, "+0x"); 164 + strscpy(p, "+0x", MAX_SYMLEN - (p - buf)); 166 165 as_hex(p + 3, off, 0); 167 166 strcat(p, "/0x"); 168 167 as_hex(p + strlen(p), len, 0);