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: 10314199 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 F3120600F6 for ; Wed, 28 Mar 2018 22:07:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC413283C5 for ; Wed, 28 Mar 2018 22:07:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0ED7283FD; Wed, 28 Mar 2018 22:07:37 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 82594283C5 for ; Wed, 28 Mar 2018 22:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=AjtfdTjISLsJOJ4TREe3JuL0SBt+YMtPPjTLS6/uQzM=; b=VhN ZcYUAAPj47r/B6/WBvnmqayNBpAWcCutaAI6xfB5AyalOXRSykUi1s8RROntuVEHi9sIGrgcK4dgH bnbQXG6dnUaEMS/6pp9elPydLhN0CAzIIXK3+uAcRgoH2KKm+pAgjlIjm6tB1BXDdcLy0si2VKwpC 3p3ZT8ZsN5XwDjDZXJ/mipFZzp3Er/WGZ2qbwxhBRmPvXhsYcHUqvP5tsWURy+ao9kqMi5ch+UMfc zG5F9GqsFCCq/+zDtGEHdYQULlrLbudEs2jLK0+mE1CnGAlDFGRnjUGFGj9wJpVGXs8hckdiQByiQ zav0UOXu9n9IOkyb10M5W7/Gmghb/Ig==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f1JE7-0000pz-UT; Wed, 28 Mar 2018 22:07:27 +0000 Received: from mout.kundenserver.de ([217.72.192.74]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f1JE5-0000oQ-7a for ath10k@lists.infradead.org; Wed, 28 Mar 2018 22:07:26 +0000 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 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== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180328_150725_578478_13F4F301 X-CRM114-Status: UNSURE ( 8.87 ) X-CRM114-Notice: Please train this message. X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maharaja Kennadyrajan , Manikanta Pubbisetty , Arnd Bergmann , Johannes Berg , netdev@vger.kernel.org, Anilkumar Kolli , Carl Huang , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, ath10k@lists.infradead.org, "Gustavo A. R. Silva" MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.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];