From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69E39C4360C for ; Sun, 6 Oct 2019 17:19:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 470422077B for ; Sun, 6 Oct 2019 17:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726620AbfJFRTP (ORCPT ); Sun, 6 Oct 2019 13:19:15 -0400 Received: from smtprelay0194.hostedemail.com ([216.40.44.194]:56694 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726508AbfJFRTP (ORCPT ); Sun, 6 Oct 2019 13:19:15 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay04.hostedemail.com (Postfix) with ESMTP id 41882180A68B1; Sun, 6 Oct 2019 17:19:13 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: road46_333b5ec2ba205 X-Filterd-Recvd-Size: 2145 Received: from XPS-9350.home (unknown [47.151.152.152]) (Authenticated sender: joe@perches.com) by omf20.hostedemail.com (Postfix) with ESMTPA; Sun, 6 Oct 2019 17:19:11 +0000 (UTC) Message-ID: Subject: i40e_pto.c: Odd use of strlcpy converted from strncpy From: Joe Perches To: Jeff Kirsher , intel-wired-lan@lists.osuosl.org, netdev Cc: Mitch Williams , Patryk =?UTF-8?Q?Ma=C5=82ek?= Date: Sun, 06 Oct 2019 10:19:10 -0700 Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.1-2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This got converted from strncpy to strlcpy but it's now not necessary to use one character less than the actual size. Perhaps the sizeof() - 1 is now not correct and it should use strscpy and a normal sizeof. from: commit 7eb74ff891b4e94b8bac48f648a21e4b94ddee64 Author: Mitch Williams Date: Mon Aug 20 08:12:30 2018 -0700 i40e: use correct length for strncpy and commit 4ff2d8540321324e04c1306f85d4fe68a0c2d0ae Author: Patryk Małek Date: Tue Oct 30 10:50:44 2018 -0700 i40e: Replace strncpy with strlcpy to ensure null termination --- drivers/net/ethernet/intel/i40e/i40e_ptp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c index 9bf1ad4319f5..627b1c02bb4b 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c @@ -700,8 +700,8 @@ static long i40e_ptp_create_clock(struct i40e_pf *pf) if (!IS_ERR_OR_NULL(pf->ptp_clock)) return 0; - strlcpy(pf->ptp_caps.name, i40e_driver_name, - sizeof(pf->ptp_caps.name) - 1); + strscpy(pf->ptp_caps.name, i40e_driver_name, sizeof(pf->ptp_caps.name)); + pf->ptp_caps.owner = THIS_MODULE; pf->ptp_caps.max_adj = 999999999; pf->ptp_caps.n_ext_ts = 0; From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Perches Date: Sun, 06 Oct 2019 10:19:10 -0700 Subject: [Intel-wired-lan] i40e_pto.c: Odd use of strlcpy converted from strncpy Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: intel-wired-lan@osuosl.org List-ID: This got converted from strncpy to strlcpy but it's now not necessary to use one character less than the actual size. Perhaps the sizeof() - 1 is now not correct and it should use strscpy and a normal sizeof. from: commit 7eb74ff891b4e94b8bac48f648a21e4b94ddee64 Author: Mitch Williams Date: Mon Aug 20 08:12:30 2018 -0700 i40e: use correct length for strncpy and commit 4ff2d8540321324e04c1306f85d4fe68a0c2d0ae Author: Patryk Ma?ek Date: Tue Oct 30 10:50:44 2018 -0700 i40e: Replace strncpy with strlcpy to ensure null termination --- drivers/net/ethernet/intel/i40e/i40e_ptp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c index 9bf1ad4319f5..627b1c02bb4b 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c @@ -700,8 +700,8 @@ static long i40e_ptp_create_clock(struct i40e_pf *pf) if (!IS_ERR_OR_NULL(pf->ptp_clock)) return 0; - strlcpy(pf->ptp_caps.name, i40e_driver_name, - sizeof(pf->ptp_caps.name) - 1); + strscpy(pf->ptp_caps.name, i40e_driver_name, sizeof(pf->ptp_caps.name)); + pf->ptp_caps.owner = THIS_MODULE; pf->ptp_caps.max_adj = 999999999; pf->ptp_caps.n_ext_ts = 0;