From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-co1nam03on0087.outbound.protection.outlook.com ([104.47.40.87]:30816 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729536AbeG0Kz7 (ORCPT ); Fri, 27 Jul 2018 06:55:59 -0400 From: "Javali, Nilesh" To: Bart Van Assche , "Martin K . Petersen" , "James E . J . Bottomley" CC: "linux-scsi@vger.kernel.org" , Dept-Eng QLogic Storage Upstream , "stable@vger.kernel.org" Subject: Re: [PATCH] qedi: Fix a potential buffer overflow Date: Fri, 27 Jul 2018 09:34:53 +0000 Message-ID: References: <20180726211037.6257-1-bart.vanassche@wdc.com> In-Reply-To: <20180726211037.6257-1-bart.vanassche@wdc.com> Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: On 7/27/18, 2:40 AM, "Bart Van Assche" 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 >Cc: >Cc: >--- > 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 =3D !!(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 =3D ipv6_en; >-- >2.18.0 > Thanks, Acked-by: Nilesh Javali