Skip to contentSkip to conversation

scsi: lpfc: replace snprintf with strscpy

PATCH New Colin King 1 participant 1 message Dec 20, 2018

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 scsi: lpfc: replace snprintf with strscpy

From: Colin Ian King <[email protected]>

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")
---
 drivers/scsi/lpfc/lpfc_scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_scsi.c +1 -1
index b4f1a840b3b4..7b0cce3b42ed 100644
@@ -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;
Signature · 1 line
2.19.1