* [PATCH] qedi: Fix a potential buffer overflow
@ 2018-07-26 21:10 Bart Van Assche
2018-07-27 9:34 ` Javali, Nilesh
2018-07-31 2:31 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: Bart Van Assche @ 2018-07-26 21:10 UTC (permalink / raw)
To: Martin K . Petersen, James E . J . Bottomley
Cc: linux-scsi, Bart Van Assche, QLogic-Storage-Upstream, stable
Tell snprintf() to store at most 255 characters in the output buffer
instead of 256. This patch avoids that smatch reports the following
warning:
drivers/scsi/qedi/qedi_main.c:891: qedi_get_boot_tgt_info() error: snprintf() is printing too much 256 vs 255
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: <QLogic-Storage-Upstream@cavium.com>
Cc: <stable@vger.kernel.org>
---
drivers/scsi/qedi/qedi_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
index 682f3ce31014..ea62180d9ec8 100644
--- a/drivers/scsi/qedi/qedi_main.c
+++ b/drivers/scsi/qedi/qedi_main.c
@@ -888,7 +888,7 @@ static void qedi_get_boot_tgt_info(struct nvm_iscsi_block *block,
ipv6_en = !!(block->generic.ctrl_flags &
NVM_ISCSI_CFG_GEN_IPV6_ENABLED);
- snprintf(tgt->iscsi_name, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n",
+ snprintf(tgt->iscsi_name, sizeof(tgt->iscsi_name), "%s\n",
block->target[index].target_name.byte);
tgt->ipv6_en = ipv6_en;
--
2.18.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] qedi: Fix a potential buffer overflow
2018-07-26 21:10 [PATCH] qedi: Fix a potential buffer overflow Bart Van Assche
@ 2018-07-27 9:34 ` Javali, Nilesh
2018-07-31 2:31 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Javali, Nilesh @ 2018-07-27 9:34 UTC (permalink / raw)
To: Bart Van Assche, Martin K . Petersen, James E . J . Bottomley
Cc: linux-scsi, Dept-Eng QLogic Storage Upstream, stable
On 7/27/18, 2:40 AM, "Bart Van Assche" <bart.vanassche@wdc.com> wrote:
>External Email
>
>Tell snprintf() to store at most 255 characters in the output buffer
>instead of 256. This patch avoids that smatch reports the following
>warning:
>
>drivers/scsi/qedi/qedi_main.c:891: qedi_get_boot_tgt_info() error:
>snprintf() is printing too much 256 vs 255
>
>Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
>Cc: <QLogic-Storage-Upstream@cavium.com>
>Cc: <stable@vger.kernel.org>
>---
> drivers/scsi/qedi/qedi_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
>index 682f3ce31014..ea62180d9ec8 100644
>--- a/drivers/scsi/qedi/qedi_main.c
>+++ b/drivers/scsi/qedi/qedi_main.c
>@@ -888,7 +888,7 @@ static void qedi_get_boot_tgt_info(struct
>nvm_iscsi_block *block,
> ipv6_en = !!(block->generic.ctrl_flags &
> NVM_ISCSI_CFG_GEN_IPV6_ENABLED);
>
>- snprintf(tgt->iscsi_name, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN,
>"%s\n",
>+ snprintf(tgt->iscsi_name, sizeof(tgt->iscsi_name), "%s\n",
> block->target[index].target_name.byte);
>
> tgt->ipv6_en = ipv6_en;
>--
>2.18.0
>
Thanks,
Acked-by: Nilesh Javali <nilesh.javali@cavium.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] qedi: Fix a potential buffer overflow
2018-07-26 21:10 [PATCH] qedi: Fix a potential buffer overflow Bart Van Assche
2018-07-27 9:34 ` Javali, Nilesh
@ 2018-07-31 2:31 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2018-07-31 2:31 UTC (permalink / raw)
To: Bart Van Assche
Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
QLogic-Storage-Upstream, stable
Bart,
> Tell snprintf() to store at most 255 characters in the output buffer
> instead of 256. This patch avoids that smatch reports the following
> warning:
Applied to 4.18/scsi-fixes. Thank you!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-31 4:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-26 21:10 [PATCH] qedi: Fix a potential buffer overflow Bart Van Assche
2018-07-27 9:34 ` Javali, Nilesh
2018-07-31 2:31 ` Martin K. Petersen
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.