Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp241729imm; Thu, 12 Jul 2018 18:27:08 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfFtGoz0eg+zZFSl8fOyvDAZrMiK2b2oshBnbvER+B/5kLuhYT5QaHSqhfyVJogHFmNg4G2 X-Received: by 2002:a17:902:b20d:: with SMTP id t13-v6mr4369924plr.121.1531445228149; Thu, 12 Jul 2018 18:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531445228; cv=none; d=google.com; s=arc-20160816; b=xdlja10x+iYtYRiMnfWw6rtjbiOFBssfXVCgyuKgzDTzRiO9cB+UUO86Q3NBcs958Y P8LuAGbS3NFiG0GFKzNEd3BsPpjJP0inSknaUzmVikXFTTuvIH06WEtJKsB5JgF3+70O nqI0dXmEpg1l4p5HQBHtarGpgpF+OrADydP1sQ7ZCxO9SUhTm/QusKDa8W1rAUfZw8Fn oiatBwP4/WCryLBbYU1ULDwgB5KNufXlbkL2q7lYpcFg4N2Di3k9sSo6E/fO5Wf0NL4H 75BhpK0vLk8enwT853x7yVcX8cvbrkg2XA/1UQUUG6nawGYn6Ag3pykySWhtyq1sBt6q EU9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:arc-authentication-results; bh=knQSTxztCDTpyao5n49QgaXzBfdyoVX4LyqflBska2w=; b=nTBu40pONWgRrJzpSaDdHvd3FMgj0KrSZVZGukjdvFCQ0pmeBd1kmDbV3Oy2rXFuzu C9OJvA9XYEjjRPzFVWz9gnyvx+KYNFoDGYITbdC5VNjM04b0mXRyV13oyAJfU6uBKf3A hyAstqW+Ch14xKjt6qRLu/2jZGoYiBWjg8Aa6/84D+zzwihCjw+bUDsnLJZxOTTn9mcX /RcaG0jYITKGPccpgmUpdfazbU5TkbOIVIJXWLHxZi0P/EwTG36t0496KtWxyPFyJFt3 +h668o8dChI0eFKiC+d2cBS2U2RnupPL46isWjDOUxuasX+FtUqooen489Q9laYNd4ga NCdw== 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 x5-v6si20884741pgr.436.2018.07.12.18.26.53; Thu, 12 Jul 2018 18:27:08 -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 S2388102AbeGMBiF (ORCPT + 99 others); Thu, 12 Jul 2018 21:38:05 -0400 Received: from nautica.notk.org ([91.121.71.147]:43020 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387896AbeGMBiE (ORCPT ); Thu, 12 Jul 2018 21:38:04 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 128EFC024; Fri, 13 Jul 2018 03:25:51 +0200 (CEST) From: Dominique Martinet Cc: Dominique Martinet , Kalle Valo , "David S. Miller" , Thomas Gleixner , Greg Kroah-Hartman , Kate Stewart , Philippe Ombredanne , Joe Perches , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/18] wireless/ti: change strncpy+truncation to strlcpy Date: Fri, 13 Jul 2018 03:25:49 +0200 Message-Id: <1531445149-19607-1-git-send-email-asmadeus@codewreck.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1531444483-17338-1-git-send-email-asmadeus@codewreck.org> References: <1531444483-17338-1-git-send-email-asmadeus@codewreck.org> To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Generated by scripts/coccinelle/misc/strncpy_truncation.cocci Signed-off-by: Dominique Martinet --- Please see https://marc.info/?l=linux-kernel&m=153144450722324&w=2 (the first patch of the serie) for the motivation behind this patch drivers/net/wireless/ti/wl1251/acx.c | 9 +-------- drivers/net/wireless/ti/wl18xx/main.c | 5 +---- drivers/net/wireless/ti/wlcore/boot.c | 5 +---- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/ti/wl1251/acx.c b/drivers/net/wireless/ti/wl1251/acx.c index f78fc3880423..c4f1a63300bb 100644 --- a/drivers/net/wireless/ti/wl1251/acx.c +++ b/drivers/net/wireless/ti/wl1251/acx.c @@ -150,14 +150,7 @@ int wl1251_acx_fw_version(struct wl1251 *wl, char *buf, size_t len) } /* be careful with the buffer sizes */ - strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version))); - - /* - * if the firmware version string is exactly - * sizeof(rev->fw_version) long or fw_len is less than - * sizeof(rev->fw_version) it won't be null terminated - */ - buf[min(len, sizeof(rev->fw_version)) - 1] = '\0'; + strlcpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version))); out: kfree(rev); diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c index ca0f936fc119..8595e9bf1cfa 100644 --- a/drivers/net/wireless/ti/wl18xx/main.c +++ b/drivers/net/wireless/ti/wl18xx/main.c @@ -1529,12 +1529,9 @@ static int wl18xx_handle_static_data(struct wl1271 *wl, struct wl18xx_static_data_priv *static_data_priv = (struct wl18xx_static_data_priv *) static_data->priv; - strncpy(wl->chip.phy_fw_ver_str, static_data_priv->phy_version, + strlcpy(wl->chip.phy_fw_ver_str, static_data_priv->phy_version, sizeof(wl->chip.phy_fw_ver_str)); - /* make sure the string is NULL-terminated */ - wl->chip.phy_fw_ver_str[sizeof(wl->chip.phy_fw_ver_str) - 1] = '\0'; - wl1271_info("PHY firmware version: %s", static_data_priv->phy_version); return 0; diff --git a/drivers/net/wireless/ti/wlcore/boot.c b/drivers/net/wireless/ti/wlcore/boot.c index f00509ea8aca..6b33951d5b34 100644 --- a/drivers/net/wireless/ti/wlcore/boot.c +++ b/drivers/net/wireless/ti/wlcore/boot.c @@ -55,12 +55,9 @@ static int wlcore_boot_parse_fw_ver(struct wl1271 *wl, { int ret; - strncpy(wl->chip.fw_ver_str, static_data->fw_version, + strlcpy(wl->chip.fw_ver_str, static_data->fw_version, sizeof(wl->chip.fw_ver_str)); - /* make sure the string is NULL-terminated */ - wl->chip.fw_ver_str[sizeof(wl->chip.fw_ver_str) - 1] = '\0'; - ret = sscanf(wl->chip.fw_ver_str + 4, "%u.%u.%u.%u.%u", &wl->chip.fw_ver[0], &wl->chip.fw_ver[1], &wl->chip.fw_ver[2], &wl->chip.fw_ver[3], -- 2.17.1