From 3cf11d776aafdb8540f4ba2c57376d2089f77dba Mon Sep 17 00:00:00 2001 From: Gerald Schaefer Date: Mon, 14 Oct 2013 15:51:31 +0200 Subject: [PATCH] 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 Signed-off-by: Martin Schwidefsky --- drivers/s390/char/monwriter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/s390/char/monwriter.c b/drivers/s390/char/monwriter.c index 4600aa10a1c6..668b32b0dc1d 100644 --- a/drivers/s390/char/monwriter.c +++ b/drivers/s390/char/monwriter.c @@ -60,7 +60,7 @@ static int monwrite_diag(struct monwrite_hdr *myhdr, char *buffer, int fcn) struct appldata_product_id id; int rc; - strcpy(id.prod_nr, "LNXAPPL"); + strncpy(id.prod_nr, "LNXAPPL", 7); id.prod_fn = myhdr->applid; id.record_nr = myhdr->record_num; id.version_nr = myhdr->version; -- 2.20.1