All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: linux-scsi@vger.kernel.org
Cc: "James E . J . Bottomley" <jejb@linux.ibm.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Achim Leubner <achim_leubner@adaptec.com>
Subject: [PATCH v2 4/8] scsi: gdth: Use scnprintf() for avoiding potential buffer overflow
Date: Sun, 15 Mar 2020 10:42:37 +0100	[thread overview]
Message-ID: <20200315094241.9086-5-tiwai@suse.de> (raw)
In-Reply-To: <20200315094241.9086-1-tiwai@suse.de>

Since snprintf() returns the would-be-output size instead of the
actual output size, the succeeding calls may go beyond the given
buffer limit.  Fix it by replacing with scnprintf().

Cc: "James E . J . Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Achim Leubner <achim_leubner@adaptec.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
v1->v2: no change

 drivers/scsi/gdth_proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index 381d849726ac..34149842cf1c 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -193,7 +193,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)
         for (i = 1;  i < MAX_RES_ARGS; i++) {
             if (reserve_list[i] == 0xff) 
                 break;
-            hlen += snprintf(hrec + hlen , 161 - hlen, ",%d", reserve_list[i]);
+            hlen += scnprintf(hrec + hlen , 161 - hlen, ",%d", reserve_list[i]);
         }
     }
     seq_printf(m,
-- 
2.16.4


  parent reply	other threads:[~2020-03-15  9:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-15  9:42 [PATCH v2 0/8] scsi: Use scnprintf() for avoiding potential buffer overflow Takashi Iwai
2020-03-15  9:42 ` [PATCH v2 1/8] scsi: aacraid: " Takashi Iwai
2020-03-15  9:42 ` [PATCH v2 2/8] scsi: be2iscsi: " Takashi Iwai
2020-03-15  9:42 ` [PATCH v2 3/8] scsi: fnic: " Takashi Iwai
2020-03-15  9:42 ` Takashi Iwai [this message]
2020-03-15  9:42 ` [PATCH v2 5/8] scsi: ipr: " Takashi Iwai
2020-03-15  9:42 ` [PATCH v2 6/8] scsi: megaraid_sas: " Takashi Iwai
2020-03-15  9:42 ` [PATCH v2 7/8] scsi: core: " Takashi Iwai
2020-03-15  9:42 ` [PATCH v2 8/8] scsi: smartpqi: " Takashi Iwai
2020-03-17 17:37 ` [PATCH v2 0/8] scsi: " 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=20200315094241.9086-5-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=achim_leubner@adaptec.com \
    --cc=jejb@linux.ibm.com \
    --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.