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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 95949C4363C for ; Wed, 7 Oct 2020 10:28:26 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id EAF79207EA for ; Wed, 7 Oct 2020 10:28:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EAF79207EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CF2A52BC7; Wed, 7 Oct 2020 12:28:23 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id E9F6E1E34 for ; Wed, 7 Oct 2020 12:28:21 +0200 (CEST) IronPort-SDR: 439rQNOLQKC/zENf413FSA1SzpNRbolDX1NWViDHjqyd11Xa/LR1c4w6f9mig7w4H9RgmCbtnE RnBinu6zXdQQ== X-IronPort-AV: E=McAfee;i="6000,8403,9766"; a="226477797" X-IronPort-AV: E=Sophos;i="5.77,346,1596524400"; d="scan'208";a="226477797" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2020 03:28:20 -0700 IronPort-SDR: srbmiHewQrYDWQNmHl8YHYs+fxX5hMnGK+huePk+1z/i4Lb/9B8oFOfpbiLXLUPj2UwxhQjU/U vKWbpt8+9AcQ== X-IronPort-AV: E=Sophos;i="5.77,346,1596524400"; d="scan'208";a="461267494" Received: from bricha3-mobl.ger.corp.intel.com ([10.213.1.245]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 07 Oct 2020 03:28:18 -0700 Date: Wed, 7 Oct 2020 11:28:12 +0100 From: Bruce Richardson To: Olivier Matz Cc: Ferruh Yigit , Ciara Loftus , dev@dpdk.org Message-ID: <20201007102812.GC680@bricha3-MOBL.ger.corp.intel.com> References: <20201007090137.5121-1-ciara.loftus@intel.com> <20201007095131.GQ21395@platinum> <20201007102638.GB680@bricha3-MOBL.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201007102638.GB680@bricha3-MOBL.ger.corp.intel.com> Subject: Re: [dpdk-dev] [PATCH] net/af_xdp: use snprintf instead of strncpy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Oct 07, 2020 at 11:26:38AM +0100, Bruce Richardson wrote: > On Wed, Oct 07, 2020 at 11:51:31AM +0200, Olivier Matz wrote: > > On Wed, Oct 07, 2020 at 10:40:32AM +0100, Ferruh Yigit wrote: > > > On 10/7/2020 10:01 AM, Ciara Loftus wrote: > > > > strncpy may leave the destination buffer not NULL terminated so use > > > > snprintf instead. > > > > > > What do you think using 'strlcpy'? > > > > Or even better, rte_strscpy() > > https://git.dpdk.org/dpdk/commit/?id=b0236c7cf761 > > > I think this is largely a matter of preference, and unless there is a good > reason not to, I tend towards strlcpy as the older and more common (till > now) interface. The main thing is just to use a function that will > guarantee dest is null-terminated here, and both strlcpy and strscpy meet > that criteria. > I'd also add that strlcpy is more likely to be recognised by tools like coverity, compared to rte_strscpy which is DPDK-specific. /Bruce