Message ID | 20170714120720.906842-6-arnd@arndb.de |
---|---|
State | Accepted |
Commit | 0606ffe26d6d7478fb5957cbc8b9cbbf14a7c68c |
Headers | show
Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp889459obm; Fri, 14 Jul 2017 05:10:52 -0700 (PDT) X-Received: by 10.101.73.72 with SMTP id q8mr14266066pgs.219.1500034252727; Fri, 14 Jul 2017 05:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500034252; cv=none; d=google.com; s=arc-20160816; b=KeAcM9sKFxb4Opy2/oGHCIZIowZDjfZEyjmHY3zBgcVpbcA9ntUoyyDJeiTfKRHZHa kb2lXfZ10tV1KJ1MHL0dG3ZSfNVvwBs/lLR3BI6sqgxMLMiipftrMafTXiaxG158+Wra +pKWS9UdZ8ew+Bdd7uAhhgYCMouPQm3rEpcsiQxmyIMB4Tr6Qp+IPauNLvZVjf7KdXCe sd3lC7Zvky7eJwwvn7Fgb4RS9eAtYp1Y8eBRHGANhHAoMgpwT3FABXjyiZlsT2a2LvM8 wQMCQY5t4Xo4nIYJDJTfA/IB5bsrx+PRXuk0le069bFZoCCjXaG/3nGT6KBrtCwq5/zR CAEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=WdO0/WzePDkJBymIpCPcqTeGfCig6MoWbpMlC5iT37Q=; b=PGMFvW9qn5Vnre8W2wXpmxBOJvQTrGvY5Mt9lz1iixaWwDZnrA7WTd0lraZ1v32AvY Sh16nzsc5RJoSY22N6jBsPnlX9pjQzHyisHeneFiRTLp2OtFljn1TOx4R36neg30crOX 9U1sKtrDbPviRnHjjClmM7IzN6nHO0aBKUKRHa1TizmlVAO1me6zx8cIOy4o4g6dHh7G vrczPw7us24McQg3imY+DHn/7vrFPp4aMVgLC0RNKWP3MHb87Qx4/Dii/RHxfrNeptwJ e+5B2D4jzudz3CjiAm4iCOlbd0Vbrbh8xcxf1r3bHEG1oVnLzRFMkgJDnp4626mGG9Ce zJyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: <linux-kernel-owner@vger.kernel.org> Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 129si6520497pgg.111.2017.07.14.05.10.52; Fri, 14 Jul 2017 05:10:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932195AbdGNMKa (ORCPT <rfc822;georgi.djakov@linaro.org> + 25 others); Fri, 14 Jul 2017 08:10:30 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:49241 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753573AbdGNMK0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 14 Jul 2017 08:10:26 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lwqoy-1dgsSK2vPM-016Lzr; Fri, 14 Jul 2017 14:08:44 +0200 From: Arnd Bergmann <arnd@arndb.de> To: linux-kernel@vger.kernel.org, Achim Leubner <achim_leubner@adaptec.com>, "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>, "Martin K. Petersen" <martin.petersen@oracle.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Linus Torvalds <torvalds@linux-foundation.org>, Guenter Roeck <linux@roeck-us.net>, akpm@linux-foundation.org, netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>, linux-scsi@vger.kernel.org, x86@kernel.org, Arnd Bergmann <arnd@arndb.de>, David Howells <dhowells@redhat.com> Subject: [PATCH 05/22] scsi: gdth: avoid buffer overflow warning Date: Fri, 14 Jul 2017 14:06:57 +0200 Message-Id: <20170714120720.906842-6-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170714120720.906842-1-arnd@arndb.de> References: <20170714120720.906842-1-arnd@arndb.de> X-Provags-ID: V03:K0:l9FMPrIo8toW5BJst/gcDIam8TLISYV4WMlqB3ERTHk5xHfU8uu 6ta5YmJaPQMLnnwer3eHQOLMIT3zvhbwHGDXlti2yDt+T4uvCB90KyyFCZCNLnywP7JsvOY ypjtDN1HmiWS2Ydum8XA2euNUtHiOiaDTcN+dem6lbZWvtrNw9iqWDaFcfvtxqeOX83SOqg dXyDWbgBim09eS2WjbWqA== X-UI-Out-Filterresults: notjunk:1; V01:K0:JTypZEVm0Dk=:5UV94W3HxB3mPysTuiacRe aoCDJ7JNkTZCFYMiMrh4s0flw1oiE2SgNC4t3LGUWtDftSZfknOXGJmgfwuCoL8Da7pxjpJgD c79vYuT7z1AG2uvNdlK+X8faY/9azLy+Ecb5RmZ2Ee5hIWazEjB26YQD6yBHLk+H8h4SbKEAh NRxS4aX6UGR5IR1BPb31dYPPwYzZUV6RHgTbAoyJiM2EyAyFusPPqbhNDs+55wg3ZX+f/HuGD Su4jnUX2YbSydkIvg6BYK7j4QUlseNc6JHLVw9BlKr1pViJKQn6KU80b46KeB1kDEaZBvAeiG l+KCJ/f4yDLNaIOkNgd6+M27LYqSeEN6Wihs+lzpBbXYRQ+R1Gj/yL3J1fQ3KOW/eSItU1dwB SpdagimvYfSTvrE0ciadUbmxQQ+MLdQdG/R5NPPolCFvBsp1z3FiQHMTY5Mt1E9pHnnxBWriC 3pDiy2A/JlDrWfDShE5bi162hiMIyP1HG+1BiDHO5VKhEP2RMbvaM67KmVbgUIMi8IGw2iu7T 5X5uootFq7kHpj9P5DctRLDh3wZT7bAnSbEg17vN8RP54dA0tQWd1mITNA+1xRMFRZxE80wb3 cH7jAwiKvwD+zO3uhbuh7NoxclurOkKleto5H6ys9hYDuH+uQxmtOObMrix4SFGdQyMhvBgJH aJgzu/gkx8kg+IjjadkAhtvum8CrLfCv+SZ5tdQdBZVBut4JozGZht+uhwdQYV29yxmqZlZDB 8CsNji3wJpgcg+Yv2HY4N+Z3QMz0B0Uow/wE+w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org |
Series |
gcc-7 -Wformat-* warnings
|
expand
|
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index facc7271f932..a4473356a9dc 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c @@ -2354,7 +2354,7 @@ static int gdth_internal_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp) inq.resp_aenc = 2; inq.add_length= 32; strcpy(inq.vendor,ha->oem_name); - sprintf(inq.product,"Host Drive #%02d",t); + snprintf(inq.product, sizeof(inq.product), "Host Drive #%02d",t); strcpy(inq.revision," "); gdth_copy_internal_data(ha, scp, (char*)&inq, sizeof(gdth_inq_data)); break;
gcc notices that we would overflow the buffer for the inquiry of the product name if we have too many adapters: drivers/scsi/gdth.c: In function 'gdth_next': drivers/scsi/gdth.c:2357:29: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=] sprintf(inq.product,"Host Drive #%02d",t); ^~~~~~~~~~~~~~~~~~~ drivers/scsi/gdth.c:2357:9: note: 'sprintf' output between 16 and 17 bytes into a destination of size 16 sprintf(inq.product,"Host Drive #%02d",t); This won't happen in practice, so just use snprintf to truncate the string. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/scsi/gdth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0