From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DE56EA04BA; Wed, 7 Oct 2020 11:51:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3EC4E2BC7; Wed, 7 Oct 2020 11:51:36 +0200 (CEST) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by dpdk.org (Postfix) with ESMTP id 35BFF1DBF for ; Wed, 7 Oct 2020 11:51:34 +0200 (CEST) Received: by mail-wr1-f65.google.com with SMTP id n15so1413784wrq.2 for ; Wed, 07 Oct 2020 02:51:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=mSK4UaJIo3tFUwotdwGDv7QsCk0cvLFDza+K6a1Xj0k=; b=E/6XRZ1U0hs/jA75TDxfDOaPW7swA/gujc1RpeD7MXxamT+6lRylri9tyKHUMLjwI0 7z5Jc3bEx1TRdSiZogENCT5Wk6lenorw46GWPEBYW02jiPziwH3w/5Yb6GIJVMawR3nO aLuuAGCTVENx9ePmJ07OE/xgA/T8eFTM7B+o83azKqQI9nV2nzKztuXpnHxC62hm9Tv0 Z9bjCn+rjKW2ZtqKgJHhMMtjBrBiV3zfU7FrgTp1vGY84VkKZrUKahHGfHy8Vp3v1EM3 EZ1cEc+rG1QpFb2rg0D8YZDsb6S49Oe3MhRZve8S37C+aWPW7gn0Gnd4Mh1mPg2hDTWp py/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=mSK4UaJIo3tFUwotdwGDv7QsCk0cvLFDza+K6a1Xj0k=; b=PLOE0ASVeQ/00TVAHMymJQs+c6qlarQ5sHTU3ETZbhxbFD38u4dDyWyG4ze6EOVXmR XTfeHKlVGQymL7egXoQZ7Zg6jV/C8kxdcSJYKeHMy2wUCA3zjh2LQqApFPRUxgbLYjpN baAjfxA5NHTAItXXV6MMo18Mr2NdGq6g6G7bGfQoepN78dHNFgaSglg9tsy53qWckQ9E 0afalD6C4uImCvBTBZKhivRjmdXB8ycWu11mw1VE3Yxj/dHVcvi6xo72JTvP4qbSIccM o24CDRoPUiVbGjnn1rM37aKqQb2Ms2UtoxSbNlJrkXKtjQkA3yCA+iU+FxsftncVU/PE JEkA== X-Gm-Message-State: AOAM530zjYPhjFxA1T6XXyv8Re5SBqCjZkY6SxCTy+D9PtTVIXuFCIS8 7bP/geTkGM/Y4HFYEShwXl5OxQ== X-Google-Smtp-Source: ABdhPJyFmrnA9X/eNBJHNLlzeqWI/YUe74N/EsdSVeLdorGfqVlTAiV80pOt0qah9KqAUBx/yg78AQ== X-Received: by 2002:adf:bbc6:: with SMTP id z6mr2579188wrg.298.1602064292878; Wed, 07 Oct 2020 02:51:32 -0700 (PDT) Received: from 6wind.com (2a01cb0c0005a600345636f7e65ed1a0.ipv6.abo.wanadoo.fr. [2a01:cb0c:5:a600:3456:36f7:e65e:d1a0]) by smtp.gmail.com with ESMTPSA id g14sm2169770wrv.25.2020.10.07.02.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Oct 2020 02:51:32 -0700 (PDT) Date: Wed, 7 Oct 2020 11:51:31 +0200 From: Olivier Matz To: Ferruh Yigit Cc: Ciara Loftus , dev@dpdk.org Message-ID: <20201007095131.GQ21395@platinum> References: <20201007090137.5121-1-ciara.loftus@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) 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 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 > > > > > Coverity issue: 362975 > > Fixes: 339b88c6a91f ("net/af_xdp: support multi-queue") > > Signed-off-by: Ciara Loftus > > --- > > drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c > > index eaf2c9c873..52495cb8fb 100644 > > --- a/drivers/net/af_xdp/rte_eth_af_xdp.c > > +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c > > @@ -1362,7 +1362,7 @@ xdp_get_channels_info(const char *if_name, int *max_queues, > > channels.cmd = ETHTOOL_GCHANNELS; > > ifr.ifr_data = (void *)&channels; > > - strncpy(ifr.ifr_name, if_name, IFNAMSIZ); > > + snprintf(ifr.ifr_name, IFNAMSIZ, "%s", if_name); > > ret = ioctl(fd, SIOCETHTOOL, &ifr); > > if (ret) { > > if (errno == EOPNOTSUPP) { > > >