Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751470AbdGQMAN (ORCPT ); Mon, 17 Jul 2017 08:00:13 -0400 Received: from mail-oi0-f43.google.com ([209.85.218.43]:35387 "EHLO mail-oi0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751280AbdGQMAL (ORCPT ); Mon, 17 Jul 2017 08:00:11 -0400 MIME-Version: 1.0 In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DD003A6C7@AcuExch.aculab.com> References: <20170714120720.906842-1-arnd@arndb.de> <20170714120720.906842-5-arnd@arndb.de> <063D6719AE5E284EB5DD2968C1650D6DD003A6C7@AcuExch.aculab.com> From: Arnd Bergmann Date: Mon, 17 Jul 2017 14:00:10 +0200 X-Google-Sender-Auth: vJBRa4cJ4ybpMkFXK3iVlO0XR9E Message-ID: Subject: Re: [PATCH 04/22] scsi: fusion: fix string overflow warning To: David Laight Cc: "linux-kernel@vger.kernel.org" , Sathya Prakash , Chaitra P B , Suganath Prabu Subramani , 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" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 864 Lines: 22 On Mon, Jul 17, 2017 at 11:17 AM, David Laight wrote: > 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. Ok, fair enough, I'll send a new version right away. Arnd