From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 06C90A0524; Tue, 20 Apr 2021 11:36:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E3BA2412B0; Tue, 20 Apr 2021 11:36:48 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 27C46411A5 for ; Tue, 20 Apr 2021 11:36:47 +0200 (CEST) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 912427F50E; Tue, 20 Apr 2021 12:36:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 912427F50E DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1618911406; bh=lR17WCOiFFhtN9Li3NHO8pqXLOPE5sYTmCuumUhzphM=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=qmHA/0T98AJkWsjzKd7qtosvoOgcFv66cb+OSi6ixUxQ7dsnBplU7dHJCwXgzfBvl VL6ZXycUN9iIpUvR7XZz5tE0vdPKj8vZPPqQLUlD1iT3vumPH+3+CDWQg93cI6L/RO 2iUvcc50vGVXhbQzjbLx7eEOKeMCRLq1H+vS+hkA= To: "Min Hu (Connor)" , dev@dpdk.org Cc: ferruh.yigit@intel.com, cristian.dumitrescu@intel.com, jerinj@marvell.com, jianjay.zhou@huawei.com, jia.guo@intel.com, g.singh@nxp.com, hemant.agrawal@nxp.com, orika@nvidia.com References: <1618839289-33224-1-git-send-email-humin29@huawei.com> <1618839289-33224-7-git-send-email-humin29@huawei.com> From: Andrew Rybchenko Organization: OKTET Labs Message-ID: <3c9175d9-f080-03f8-0d29-738b89f511b6@oktetlabs.ru> Date: Tue, 20 Apr 2021 12:36:46 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <1618839289-33224-7-git-send-email-humin29@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 06/10] lib/librte_pipeline: fix the use of unsafe strcpy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 4/19/21 4:34 PM, Min Hu (Connor) wrote: > From: HongBo Zheng > > 'strcpy' is called in rte_swx_ctl_table_info_get, this function > is unsafe, use 'strncpy' instead. > > Fixes: 393b96e2aa2a ("pipeline: add SWX pipeline query API") > Cc: stable@dpdk.org > > Signed-off-by: HongBo Zheng > Signed-off-by: Min Hu (Connor) > --- > lib/librte_pipeline/rte_swx_pipeline.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_pipeline/rte_swx_pipeline.c b/lib/librte_pipeline/rte_swx_pipeline.c > index 4455d91..d4db4dd 100644 > --- a/lib/librte_pipeline/rte_swx_pipeline.c > +++ b/lib/librte_pipeline/rte_swx_pipeline.c > @@ -9447,8 +9447,8 @@ rte_swx_ctl_table_info_get(struct rte_swx_pipeline *p, > if (!t) > return -EINVAL; > > - strcpy(table->name, t->name); > - strcpy(table->args, t->args); > + strncpy(table->name, t->name, RTE_SWX_CTL_NAME_SIZE); > + strncpy(table->args, t->args, RTE_SWX_CTL_NAME_SIZE); strlcpy() should be used in fact, since strncpy() has problems as well. > table->n_match_fields = t->n_fields; > table->n_actions = t->n_actions; > table->default_action_is_const = t->default_action_is_const; >