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: 10314201 X-Patchwork-Delegate: kvalo@adurom.com 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 1C03E605B4 for ; Wed, 28 Mar 2018 22:07:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 072F9283C5 for ; Wed, 28 Mar 2018 22:07:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F00A928418; Wed, 28 Mar 2018 22:07:47 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 83E4D283C5 for ; Wed, 28 Mar 2018 22:07:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753501AbeC1WHa (ORCPT ); Wed, 28 Mar 2018 18:07:30 -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-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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];