From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751466AbdGQJRx convert rfc822-to-8bit (ORCPT ); Mon, 17 Jul 2017 05:17:53 -0400 Received: from smtp-out6.electric.net ([192.162.217.184]:61699 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751178AbdGQJRv (ORCPT ); Mon, 17 Jul 2017 05:17:51 -0400 From: David Laight To: "'Arnd Bergmann'" , "linux-kernel@vger.kernel.org" , Sathya Prakash , Chaitra P B , Suganath Prabu Subramani CC: Greg Kroah-Hartman , Linus Torvalds , Guenter Roeck , "akpm@linux-foundation.org" , "netdev@vger.kernel.org" , "David S . Miller" , "James E . J . Bottomley" , "Martin K . Petersen" , "linux-scsi@vger.kernel.org" , "x86@kernel.org" , Helge Deller , "MPT-FusionLinux.pdl@broadcom.com" Subject: RE: [PATCH 04/22] scsi: fusion: fix string overflow warning Thread-Topic: [PATCH 04/22] scsi: fusion: fix string overflow warning Thread-Index: AQHS/Jom5nlNr28ei0C9DBAbziR/TaJXwTcg Date: Mon, 17 Jul 2017 09:17:38 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6DD003A6C7@AcuExch.aculab.com> References: <20170714120720.906842-1-arnd@arndb.de> <20170714120720.906842-5-arnd@arndb.de> In-Reply-To: <20170714120720.906842-5-arnd@arndb.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 156.67.243.126 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuExch.aculab.com X-TLS: TLSv1:AES128-SHA:128 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann > Sent: 14 July 2017 13:07 > gcc points out a theorerical string overflow: > > drivers/message/fusion/mptbase.c: In function 'mpt_detach': > drivers/message/fusion/mptbase.c:2103:17: error: '%s' directive writing up to 31 bytes into a region > of size 28 [-Werror=format-overflow=] > sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name); > ^~~~~ > drivers/message/fusion/mptbase.c:2103:2: note: 'sprintf' output between 13 and 44 bytes into a > destination of size 32 > > We can simply double the size of the local buffer here to be on the > safe side. I think I'd change it to snprintf() as well. Saves any worries if ioc->name isn't '\0' terminated. David From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Laight Subject: RE: [PATCH 04/22] scsi: fusion: fix string overflow warning Date: Mon, 17 Jul 2017 09:17:38 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6DD003A6C7@AcuExch.aculab.com> References: <20170714120720.906842-1-arnd@arndb.de> <20170714120720.906842-5-arnd@arndb.de> Mime-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8BIT Cc: Greg Kroah-Hartman , Linus Torvalds , Guenter Roeck , "akpm@linux-foundation.org" , "netdev@vger.kernel.org" , "David S . Miller" , "James E . J . Bottomley" , "Martin K . Petersen" , "linux-scsi@vger.kernel.org" , "x86@kernel.org" , Helge Deller , "MPT-FusionLinux.pdl@broadcom.com" To: 'Arnd Bergmann' , "linux-kernel@vger.kernel.org" , Sathya Prakash , Chaitra P B , Suganath Prabu Subramani Return-path: In-Reply-To: <20170714120720.906842-5-arnd@arndb.de> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org From: Arnd Bergmann > Sent: 14 July 2017 13:07 > gcc points out a theorerical string overflow: > > drivers/message/fusion/mptbase.c: In function 'mpt_detach': > drivers/message/fusion/mptbase.c:2103:17: error: '%s' directive writing up to 31 bytes into a region > of size 28 [-Werror=format-overflow=] > sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name); > ^~~~~ > drivers/message/fusion/mptbase.c:2103:2: note: 'sprintf' output between 13 and 44 bytes into a > destination of size 32 > > We can simply double the size of the local buffer here to be on the > safe side. I think I'd change it to snprintf() as well. Saves any worries if ioc->name isn't '\0' terminated. David