Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp241651imm; Thu, 12 Jul 2018 18:27:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcqupaATU9w9Xu5afVc8+IEFVY9JfMfp+4pxw0JbRYyGOqV1yVX0yny7y1Xz/1YTsYYljKG X-Received: by 2002:a17:902:28a6:: with SMTP id f35-v6mr4301100plb.110.1531445220223; Thu, 12 Jul 2018 18:27:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531445220; cv=none; d=google.com; s=arc-20160816; b=sLUVqQ9Tn63Ndd7GTnHUojxdqpfogrvMPHWxPyWkMZj1qGIfmIRtivt4VUYdzgIUvM fok1XUIuG9EeQGYxYc+EquQBdg4MKEX3Nv5EPoJVeNF4Blx5DD0FOqL1wcNkiVZqlDE1 Yw1cnAkwLSShq+pRnGjqTRVYAy405WSYMGD5DA7cUiLK/fHQWqjrB1hLYME6tohBGfVc /lUgIQ74OLnSnBp183N28QZoh1iMBvqOUH85IU8crBWf8ri1/oQsVpjyBY/cCmD1fR1Q jmlcD8Ppo9Jyv3nq5R1Oj/iYNpnO2yVNR6HTMmOvIrmrorgaWKdU7hB1ddbd/R9PLI+k BGVA== 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=Py2rvwBA063qIoxRPBcBf1XV8lwy+lnn3rnvDvlPrnc=; b=M6n6PGFw0u4P4SyUArO4ma4Ns7Xcs9PdMUMgeMAhobdjC64XFAO6X0sE3EkkEoDdeY lIlDsS6JwSPTPwgKnjIc0Gq4A+0zqCUWYaay72dBNVo51efEAR7EaarnKdt1Zwxu4z3T aTzf0Ug2oTbuxyIkabjQP2qo+yzWDtj6xEh8GZqVc+NzVzg1X5lw0cfkeiu0m9g0cRxW 6RFsgMAXnL+9eS8T5yfUkp0E5Qgt4cXUpklefOzhPc97FVtUfaSfLpE3b5fniW+950xX ikgg7Z7Ekx8Ncas9XLfUrZBkgVXb/JxLpswIbr0EW09OyDGI3r5wbKjh3YjZTZhE8zlE GqRg== 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 j33-v6si16545533pgm.584.2018.07.12.18.26.45; Thu, 12 Jul 2018 18:27:00 -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 S2388022AbeGMBhy (ORCPT + 99 others); Thu, 12 Jul 2018 21:37:54 -0400 Received: from nautica.notk.org ([91.121.71.147]:42999 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387896AbeGMBhy (ORCPT ); Thu, 12 Jul 2018 21:37:54 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 8B7C2C022; Fri, 13 Jul 2018 03:25:40 +0200 (CEST) From: Dominique Martinet Cc: Dominique Martinet , Yisen Zhuang , Salil Mehta , "David S. Miller" , Matthias Brugger , Lin Yun Sheng , stephen hemminger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/18] hisilicon: change strncpy+truncation to strlcpy Date: Fri, 13 Jul 2018 03:25:39 +0200 Message-Id: <1531445139-19439-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/ethernet/hisilicon/hns/hns_ethtool.c | 7 ++----- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c index 2e14a3ae1d8b..35b4d72d1997 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c @@ -638,12 +638,9 @@ static void hns_nic_get_drvinfo(struct net_device *net_dev, { struct hns_nic_priv *priv = netdev_priv(net_dev); - strncpy(drvinfo->version, HNAE_DRIVER_VERSION, + strlcpy(drvinfo->version, HNAE_DRIVER_VERSION, sizeof(drvinfo->version)); - drvinfo->version[sizeof(drvinfo->version) - 1] = '\0'; - - strncpy(drvinfo->driver, HNAE_DRIVER_NAME, sizeof(drvinfo->driver)); - drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0'; + strlcpy(drvinfo->driver, HNAE_DRIVER_NAME, sizeof(drvinfo->driver)); strncpy(drvinfo->bus_info, priv->dev->bus->name, sizeof(drvinfo->bus_info)); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 40c0425b4023..630c8d186707 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -493,13 +493,10 @@ static void hns3_get_drvinfo(struct net_device *netdev, struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = priv->ae_handle; - strncpy(drvinfo->version, hns3_driver_version, + strlcpy(drvinfo->version, hns3_driver_version, sizeof(drvinfo->version)); - drvinfo->version[sizeof(drvinfo->version) - 1] = '\0'; - - strncpy(drvinfo->driver, h->pdev->driver->name, + strlcpy(drvinfo->driver, h->pdev->driver->name, sizeof(drvinfo->driver)); - drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0'; strncpy(drvinfo->bus_info, pci_name(h->pdev), sizeof(drvinfo->bus_info)); -- 2.17.1