All of lore.kernel.org
 help / color / mirror / Atom feed
From: Colin King <colin.king@canonical.com>
To: James Smart <jsmart2021@gmail.com>,
	Dick Kennedy <dick.kennedy@broadcom.com>,
	"James E . J . Bottomley" <jejb@linux.ibm.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][next] scsi: lpfc: replace snprintf with strscpy
Date: Thu, 20 Dec 2018 17:08:05 +0000	[thread overview]
Message-ID: <20181220170805.17802-1-colin.king@canonical.com> (raw)

From: Colin Ian King <colin.king@canonical.com>

Using snprintf without a format specifier is potentially risky if the
string phba->ModelDesc contains format specifiers. Replace this with
the safer and more efficient strscpy.

Cleans up clang warning:
drivers/scsi/lpfc/lpfc_scsi.c:4543:31: warning: format string is not a
string literal (potentially insecure) [-Wformat-security]

Fixes: 5021267af132 ("scsi: lpfc: Adding ability to reset chip via pci bus reset")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/scsi/lpfc/lpfc_scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index b4f1a840b3b4..7b0cce3b42ed 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -4540,7 +4540,7 @@ lpfc_info(struct Scsi_Host *host)
 	memset(lpfcinfobuf, 0, sizeof(lpfcinfobuf));
 	if (phba && phba->pcidev){
 		/* Model Description */
-		scnprintf(tmp, sizeof(tmp), phba->ModelDesc);
+		strscpy(tmp, phba->ModelDesc, sizeof(tmp));
 		if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
 		    sizeof(lpfcinfobuf))
 			goto buffer_done;
-- 
2.19.1


WARNING: multiple messages have this Message-ID (diff)
From: Colin King <colin.king@canonical.com>
To: James Smart <jsmart2021@gmail.com>,
	Dick Kennedy <dick.kennedy@broadcom.com>,
	"James E . J . Bottomley" <jejb@linux.ibm.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][next] scsi: lpfc: replace snprintf with strscpy
Date: Thu, 20 Dec 2018 17:08:05 +0000	[thread overview]
Message-ID: <20181220170805.17802-1-colin.king@canonical.com> (raw)

From: Colin Ian King <colin.king@canonical.com>

Using snprintf without a format specifier is potentially risky if the
string phba->ModelDesc contains format specifiers. Replace this with
the safer and more efficient strscpy.

Cleans up clang warning:
drivers/scsi/lpfc/lpfc_scsi.c:4543:31: warning: format string is not a
string literal (potentially insecure) [-Wformat-security]

Fixes: 5021267af132 ("scsi: lpfc: Adding ability to reset chip via pci bus reset")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/scsi/lpfc/lpfc_scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index b4f1a840b3b4..7b0cce3b42ed 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -4540,7 +4540,7 @@ lpfc_info(struct Scsi_Host *host)
 	memset(lpfcinfobuf, 0, sizeof(lpfcinfobuf));
 	if (phba && phba->pcidev){
 		/* Model Description */
-		scnprintf(tmp, sizeof(tmp), phba->ModelDesc);
+		strscpy(tmp, phba->ModelDesc, sizeof(tmp));
 		if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) > 		    sizeof(lpfcinfobuf))
 			goto buffer_done;
-- 
2.19.1

             reply	other threads:[~2018-12-20 17:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-20 17:08 Colin King [this message]
2018-12-20 17:08 ` [PATCH][next] scsi: lpfc: replace snprintf with strscpy Colin King

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=20181220170805.17802-1-colin.king@canonical.com \
    --to=colin.king@canonical.com \
    --cc=dick.kennedy@broadcom.com \
    --cc=jejb@linux.ibm.com \
    --cc=jsmart2021@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.