From patchwork Fri Jul 14 12:07:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9840807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F2962602BD for ; Fri, 14 Jul 2017 12:13:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5E3A28752 for ; Fri, 14 Jul 2017 12:13:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAD3C2876E; Fri, 14 Jul 2017 12:13:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7581428752 for ; Fri, 14 Jul 2017 12:13:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932215AbdGNMNZ (ORCPT ); Fri, 14 Jul 2017 08:13:25 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:59521 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932120AbdGNMNW (ORCPT ); Fri, 14 Jul 2017 08:13:22 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0MC1A0-1dN9jt3sxM-008sgp; Fri, 14 Jul 2017 14:11:38 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Darren Hart , Andy Shevchenko 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, Arnd Bergmann , Mario Limonciello , Arvind Yadav , platform-driver-x86@vger.kernel.org Subject: [PATCH 17/22] platform/x86: alienware-wmi: fix format string overflow warning Date: Fri, 14 Jul 2017 14:07:09 +0200 Message-Id: <20170714120720.906842-18-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:4XOtuPAALKuS8DxTM63tcbwL/8NN7O+VNaaO6IXY6yExvaKs9+q fWY2mugP7xyQbW0zj+EObM2c92gx7ooN3s1U1zISxWscIUNvoQRnKyY8cPwpnpFJCVyKnNi xgBlP4ItAiHHzLnKaokDKlfS2WynwCcDb1aZzYO3moOl9zYpAxcMfiJ4tVk1pDKt9GHMmTA KjB4noAhvFZAyliZHyZwg== X-UI-Out-Filterresults: notjunk:1; V01:K0:BJ57ShxF6VI=:L5QQmo8R5VBld6R39q0TU4 kp/LlEYlQ+riAvJ0clOxpBbc1VmU5QgJExe2lEyHC26qyd82l+a6ojUu7XXD8svC/VQUr3Van K2rBCXI09zlpDCPEgFFiOHfImcuiQlHPD/BL4VW0aH+Zz2VPR20GtqzLORIjqZHBtxDV4zUzW 6OCz1+Pw+16RVoXSR48OTE4nu0PF3oZfnG8o0ckxiStJkXyBmNpO+7TLmAKxsarLWQs+fczKK 4JWI0Ex4csElmdBQP2E79Lwtp8F9hU0+nz/ZdE3MnAkqlBIg/BoYK58ArsDf2NsISBvxFM80/ L0c754AluW2rabgrNlPU9BBeIwaBCn+HhSw/EaFDf0xSjb16f0k2LO3UxQLFnYDBni6MGRrU+ lbXBKdvRZKUdKOnpwIJTzj856RPrwrnn2nsdGV7kdJNLXFN1Me5/bZ9+sVYb3rZBYOVhWTSra ty+A6fMi5xVwRVKrHOYHQbhrYmhJftb6pliBs1m9uvVMWYN8h53/NwAra8tCn3htySfi/GXeD vwbaec6p/voorH9LiN7VDwTaXmMZMXRjrnEQDAwzpVImkZqyFNfHmWSaHQYWfnu9WzSMr8QnM /pj2hvPyCoyzvpExfYw1qFOij8imdbQDx/dmGyWRWfiDd9dgn8LsTC4OBw7PyAPE3qczWNNdN wREjMiAOJqzjDqDEIxW6sWzJmt9mqhkv2U5KVqFrDrA7GTP7kfNWtKoAr+5xB3LuGBfGW9TU+ LKK4LZazIWdbJFpCcSqVUWlpCLhE+QUkpaXSOA== Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP gcc points out a possible format string overflow for a large value of 'zone': drivers/platform/x86/alienware-wmi.c: In function 'alienware_wmi_init': drivers/platform/x86/alienware-wmi.c:461:24: error: '%02X' directive writing between 2 and 8 bytes into a region of size 6 [-Werror=format-overflow=] sprintf(buffer, "zone%02X", i); ^~~~ drivers/platform/x86/alienware-wmi.c:461:19: note: directive argument in the range [0, 2147483646] sprintf(buffer, "zone%02X", i); ^~~~~~~~~~ drivers/platform/x86/alienware-wmi.c:461:3: note: 'sprintf' output between 7 and 13 bytes into a destination of size 10 While the zone should never be that large, it's easy to make the buffer a few bytes longer so gcc can prove this to be safe. Signed-off-by: Arnd Bergmann Signed-off-by: Mario Limonciello --- drivers/platform/x86/alienware-wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c index 0831b428c217..acc01242da82 100644 --- a/drivers/platform/x86/alienware-wmi.c +++ b/drivers/platform/x86/alienware-wmi.c @@ -421,7 +421,7 @@ static DEVICE_ATTR(lighting_control_state, 0644, show_control_state, static int alienware_zone_init(struct platform_device *dev) { int i; - char buffer[10]; + char buffer[13]; char *name; if (interface == WMAX) {