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

s390/monwriter: fix smatch warning for strcpy()

This patch fixes the following smatch warning:
monwrite_diag() error: strcpy() '"LNXAPPL"' too large for 'id.prod_nr'
(8 vs 7)
Using strcpy() is wrong, because it also copies the terminating null
byte, but in this case the extra copied null byte will be overwritten
right after the strcpy(), so there is no real problem here.
Use strncpy() to fix the warning.

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Gerald Schaefer and committed by
Martin Schwidefsky
3cf11d77 57f47ba0

+1 -1
+1 -1
drivers/s390/char/monwriter.c
··· 60 60 struct appldata_product_id id; 61 61 int rc; 62 62 63 - strcpy(id.prod_nr, "LNXAPPL"); 63 + strncpy(id.prod_nr, "LNXAPPL", 7); 64 64 id.prod_fn = myhdr->applid; 65 65 id.record_nr = myhdr->record_num; 66 66 id.version_nr = myhdr->version;