From patchwork Wed Mar 28 22:06:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 132547 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp999072ljb; Wed, 28 Mar 2018 15:07:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx48lm7qbr94MM1V/nMT7wZNTS659SCPxEFioWJRWjItZSWD1UO3QrDdxxnfEWI82UFgs+hwl X-Received: by 10.101.101.7 with SMTP id x7mr3759318pgv.130.1522274853788; Wed, 28 Mar 2018 15:07:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522274853; cv=none; d=google.com; s=arc-20160816; b=DZjAZVtKCdefsbxiB2SBeuTimLKA357kWrQH1kRIRT8YllfAo1G7o1aCru1VuS1bg1 CyDc+TJEUB497puGFaFFnwHbesC0rUB1otlSI/nnEZAqI07dZs6RmG+Luzwj65W60ksg WR7ub59mdJ1WSZiqa3q7fyeV59DJ8KT53vNrCU1R0eiZiuQLe3927Nb9xXmDdo5mGrYj VjhWbH+VEH0fCY/k3z09FVSY59FuSXU4wEvlnJPF5bKXH+BcZUbgLEGeLY5L77DTJ8oi QoANiv4Fv1mpZSZLNTDCdAmB6XLJKcrIzykgrjr0rJHR1+cAaYPM/w8vpPwgxCn7SzIN 7WYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XX8VloUTUyMK5a4WZ5BX5FwVdxatCWhLbqN6EsXYgAU=; b=pimnNYdhZWhoRqgmdalJaZMJRcVOASoMJCb3zK2i8I5nVN9aK78q8u4bTI6/szn/7x 4M5Rd4PcZoa7FswLUMu2qyDcxFZ1YmLHXmtZ1kzSOQCthMg2ShhiuYwfo5ilDyxIoG+u reHJhg/pDGfwnlj2URGYCohpOZ1qWZ/vWcOsvAanBufBmgw+eXcx+kluDSJpOqoq+VhF cCEo846zXjnAzpMIYB4lzCcRWlySxI8qjDtc2H8aRXC/inpBtXIWtlnQOE6DR+rv8ZXQ e2q+MsoVHlqCIPj8nAL8X+yaITHTWPt18W1QdKdZB8ACTVbNcqxmHCiVC0Gd4I9kvk0p 58rw== 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: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e8si3082503pgf.679.2018.03.28.15.07.33; Wed, 28 Mar 2018 15:07:33 -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 S1753591AbeC1WHb (ORCPT + 28 others); Wed, 28 Mar 2018 18:07:31 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:46491 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751976AbeC1WH3 (ORCPT ); Wed, 28 Mar 2018 18:07:29 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0M7Kru-1eexGw3MRC-00x4SE; Thu, 29 Mar 2018 00:06:40 +0200 From: Arnd Bergmann To: Kalle Valo Cc: Arnd Bergmann , Manikanta Pubbisetty , Anilkumar Kolli , Carl Huang , "Gustavo A. R. Silva" , Johannes Berg , Maharaja Kennadyrajan , ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ath10k: avoid possible string overflow Date: Thu, 29 Mar 2018 00:06:10 +0200 Message-Id: <20180328220635.3704458-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:ol4ZTKAL9L6O2dOmcE8jghQF/h9jA3ll+3QK4mGY2XBNiOgkAye jJ5JwTJ9WNM2mjPZve1OJNwQnjM3eRmgDU0XIarJYqRW28cEBDfLTFfLZJLjDf/xMEPoCB6 IRDWVdVe7ShViKZBe/jwaS8rKckRLDA2CVZQHA4QiHqHN8ZgAxSTWtTceKq8fmPkboo6Qnr 3aDZz2HnwhvkGJZ4OKvjg== X-UI-Out-Filterresults: notjunk:1; V01:K0:I/KSEhES4yo=:HzyI0XbLO53J7iZhSGZlPy JPyjzObmnuy6g5Iq9lC6TwcMxafBLev4UBL1MriYposCGsfUg+84P3oRvFAzr56x3ETdDXJ/j at+bT/267zTnsFBrnB+7uE1G89PxQg/tVWwqom1wr1+q2m38DHQ++NPC+mQgvr1HE7pqmvUgi 2rBy8qqvq8D+TsQS88hqXeLqfN0dFn+zlQc1gGzHI1UPk5MDhygjBg3crDODbOsP+WSuXxf8Q EFdjcGr8xaJnQMX9Afqm44AWpWFxJf55moT+aA/FtcDuKkiD960zs8IIRAD89JKqUY+G9WQxL lw4c3ttBGsWSJV7QBRThbnph1p0+WRWoxAXgiRBWSpzes9u4nIP3LL0BsXvQnW8opiWHt4mmh DReUlUUzfsUDyWwL7ZVD7YwfMJeR+zv+SsuE0R4Lrh7/ygWx3qru/0eaTYzEvZEf53KEAFjfe gNk/lV+9+tRrgTLE4lkR1k3Qbxdal0IsQWa68hKJokDHnj6H37Kq1MgIZQnSzd1/G7ua5MpXI SJJu23udL4TneOGK36REXvEVhEuqxBydiesLfPsRwvTa7baBDfYdMpq3exK0jN1v5UrjvjdSJ PCIyOxAGWyJ4XGT1Xlzq+TAxOY2CGJTEd50aJO9ujfBfYCtDZhqUkRI/a0pOVpMSb/QswqTDW DhPLOB946ItnYL50L0oEgb5ZJSd4/cT1sUW3tTrRbdytKu9jZmgvDs39XKQbf1L20EOt8ck5I GlZf9fa7IaxXIrc4V1dWZB0z0klq4I7IjDAifQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The way that 'strncat' is used here raised a warning in gcc-8: drivers/net/wireless/ath/ath10k/wmi.c: In function 'ath10k_wmi_tpc_stats_final_disp_tables': drivers/net/wireless/ath/ath10k/wmi.c:4649:4: error: 'strncat' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation] Effectively, this is simply a strcat() but the use of strncat() suggests some form of overflow check. Regardless of whether this might actually overflow, using strlcat() instead of strncat() avoids the warning and makes the code more robust. Fixes: bc64d05220f3 ("ath10k: debugfs support to get final TPC stats for 10.4 variants") Signed-off-by: Arnd Bergmann --- drivers/net/wireless/ath/ath10k/wmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.9.0 diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c index 9649bb752bbd..42522ed115f3 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.c +++ b/drivers/net/wireless/ath/ath10k/wmi.c @@ -4309,7 +4309,7 @@ static void ath10k_tpc_config_disp_tables(struct ath10k *ar, rate_code[i], type); snprintf(buff, sizeof(buff), "%8d ", tpc[j]); - strncat(tpc_value, buff, strlen(buff)); + strlcat(tpc_value, buff, sizeof(tpc_value)); } tpc_stats->tpc_table[type].pream_idx[i] = pream_idx; tpc_stats->tpc_table[type].rate_code[i] = rate_code[i]; @@ -4646,7 +4646,7 @@ ath10k_wmi_tpc_stats_final_disp_tables(struct ath10k *ar, rate_code[i], type, pream_idx); snprintf(buff, sizeof(buff), "%8d ", tpc[j]); - strncat(tpc_value, buff, strlen(buff)); + strlcat(tpc_value, buff, sizeof(tpc_value)); } tpc_stats->tpc_table_final[type].pream_idx[i] = pream_idx; tpc_stats->tpc_table_final[type].rate_code[i] = rate_code[i];