mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: linux-scsi@vger.kernel.org,
	"James E . J . Bottomley" <jejb@linux.vnet.ibm.com>,
	QLogic-Storage-Upstream@cavium.com,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Nicolas Pitre <nico@linaro.org>, Andi Kleen <ak@linux.intel.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Saurav Kashyap <saurav.kashyap@cavium.com>,
	"Dupuis, Chad" <chad.dupuis@cavium.com>,
	Arun Easi <arun.easi@cavium.com>,
	Nilesh Javali <nilesh.javali@cavium.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 6/6] scsi: qedf: use correct strncpy() size
Date: Fri,  2 Feb 2018 14:12:20 +0100	[thread overview]
Message-ID: <20180202131225.1658853-7-arnd@arndb.de> (raw)
In-Reply-To: <20180202131225.1658853-1-arnd@arndb.de>

gcc-8 warns during link-time optimization that the strncpy() call
passes the size of the source buffer rather than the destination:

drivers/scsi/qedf/qedf_dbg.c: In function 'qedf_uevent_emit':
include/linux/string.h:253: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]

This changes it to strscpy() with the correct length, guaranteeing
a properly nul-terminated string of the right size.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/qedf/qedf_dbg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qedf/qedf_dbg.c b/drivers/scsi/qedf/qedf_dbg.c
index e023f5d0dc12..bd1cef25a900 100644
--- a/drivers/scsi/qedf/qedf_dbg.c
+++ b/drivers/scsi/qedf/qedf_dbg.c
@@ -160,7 +160,7 @@ qedf_uevent_emit(struct Scsi_Host *shost, u32 code, char *msg)
 	switch (code) {
 	case QEDF_UEVENT_CODE_GRCDUMP:
 		if (msg)
-			strncpy(event_string, msg, strlen(msg));
+			strscpy(event_string, msg, sizeof(event_string));
 		else
 			sprintf(event_string, "GRCDUMP=%u", shost->host_no);
 		break;
-- 
2.9.0

  parent reply	other threads:[~2018-02-02 13:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20180202131225.1658853-1-arnd@arndb.de>
2018-02-02 13:12 ` [PATCH 1/6] scsi: fc_encode: work around strncpy size warnings Arnd Bergmann
2018-02-02 13:12 ` [PATCH 2/6] scsi: NCR53c406a: avoid section mismatch with LTO Arnd Bergmann
2018-02-09 23:47   ` Martin K. Petersen
2018-02-02 13:12 ` [PATCH 3/6] scsi: sym53c416: " Arnd Bergmann
2018-02-09 23:47   ` Martin K. Petersen
2018-02-02 13:12 ` [PATCH 4/6] scsi: qedf: fix LTO-enabled build Arnd Bergmann
2018-02-07 15:38   ` Chad Dupuis
2018-02-09 23:24   ` Martin K. Petersen
2018-02-02 13:12 ` [PATCH 5/6] scsi: qedi: fix building with LTO Arnd Bergmann
2018-02-05  6:08   ` Rangankar, Manish
2018-02-07  1:24   ` Martin K. Petersen
2018-02-02 13:12 ` Arnd Bergmann [this message]
2018-02-05  2:56   ` [PATCH 6/6] scsi: qedf: use correct strncpy() size kbuild test robot
2018-02-07 16:26   ` Chad Dupuis
2018-02-09 23:36   ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180202131225.1658853-7-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=QLogic-Storage-Upstream@cavium.com \
    --cc=ak@linux.intel.com \
    --cc=arun.easi@cavium.com \
    --cc=chad.dupuis@cavium.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=nico@linaro.org \
    --cc=nilesh.javali@cavium.com \
    --cc=saurav.kashyap@cavium.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®