Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: proc: use snprintf() for the host name
@ 2026-11-09  3:38 shao.mingyin
  2026-11-09  3:46 ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: shao.mingyin @ 2026-11-09  3:38 UTC (permalink / raw)
  To: mkp, linux-scsi; +Cc: James.Bottomley, linux-kernel

From: Shao Mingyin <shao.mingyin@zte.com.cn>

scsi_proc_host_add() and scsi_proc_host_rm() format host_no into a
10-byte buffer with sprintf().  host_no is an unsigned int, and once
it grows past nine digits the %d output plus the terminator no longer
fits; use snprintf().

Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
index fdc355d783da..d1f474c28720 100644
--- a/drivers/scsi/scsi_proc.c
+++ b/drivers/scsi/scsi_proc.c
@@ -230,7 +230,7 @@ void scsi_proc_host_add(struct Scsi_Host *shost)
 	if (!e)
 		goto err;
 
-	sprintf(name,"%d", shost->host_no);
+	snprintf(name, sizeof(name), "%d", shost->host_no);
 	p = proc_create_data(name, S_IRUGO | S_IWUSR, e->proc_dir,
 			     &proc_scsi_ops, shost);
 	if (!p)
@@ -260,7 +260,7 @@ void scsi_proc_host_rm(struct Scsi_Host *shost)
 	if (!e)
 		return;
 
-	sprintf(name,"%d", shost->host_no);
+	snprintf(name, sizeof(name), "%d", shost->host_no);
 	remove_proc_entry(name, e->proc_dir);
 }
 /**

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-09  5:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09  3:38 [PATCH] scsi: proc: use snprintf() for the host name shao.mingyin
2026-11-09  3:46 ` sashiko-bot
2026-11-09  5:56   ` shao.mingyin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox