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 1DF0142D99; Fri, 30 Jun 2023 20:08:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E8F71410FC; Fri, 30 Jun 2023 20:08:55 +0200 (CEST) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mails.dpdk.org (Postfix) with ESMTP id 64F0440EDB for ; Fri, 30 Jun 2023 20:08:54 +0200 (CEST) Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-262d9e75438so1388964a91.2 for ; Fri, 30 Jun 2023 11:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688148533; x=1690740533; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=z6dvEr0TfE3zohDeN3Z77IrnD3JTLqnQyqS65bI3tCQ=; b=xmRGtl6UVMU3THsdrsS5FkSoS77do8Op8i0wTt5OI86YYSBh1HNbIy4uS7VDVyCWhs Ml6s6u9xAlJbzUWNnPBMGrPhMkZJRoC3OapVjoDMh4+xK51m9KR6iCWeBD50aoEp6jSQ EerTKHFUgfiViIcdPBUZejVvZbb2RIvyp8u3O7eqeiU5bPF7kIqiJiPFzkNHjNusyPJx X0U6wcxjGR67yKO/PoH8BtkK2C7elFF1QV7A3iSWDRUW/ZYUV5pm8MT2lMBiQZhahWND wGmEA524BdmoxJkZgEIuF1kKoiRUDNVA00snF2DfNt3eMpunKzyM21qLL+Ex/bt/D9PK xKXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688148533; x=1690740533; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z6dvEr0TfE3zohDeN3Z77IrnD3JTLqnQyqS65bI3tCQ=; b=RCg3hr7M1OTYq1FmLRUfOi7QPPaPrY3sakvdo7MZEKQhk++pChZ0rfKosiX6NJF227 QIGWN9MoRLQiwjfN0pVYKGw/1Aqwywnb0h5fOUYhFZFW2bxWRw1N8Hlt5lxLKTnLalVB sMsUJekoKOAi/Dxn3OzPKvtlsf12TXRstaf+Z3SGtlFGPzeZM6bNGFJon6wEZnL3RNHz LsZJELEw3YK7ieJFs7TX92T2wCeDCuNzFPqVD6ysx14VWW/4xt77DEtrnxdA05gaL0lE UuzpTygPVjG+zBz5gOmJg/iLIrEGQ5G8IsUU2YLCkWC3IfjK3KMjHwEDvmKBBeqPLjZy lgLA== X-Gm-Message-State: ABy/qLaARla55t0GbY4ZPxAj7zZ6kWXByesv8uK58Yg0mkFyx1uQJUbg FpQMY43Y7davHfsbuhTOLrhjHg== X-Google-Smtp-Source: APBJJlFwR2hVtaslcAqYFWf3KL3m2d8eLl8f1B6oXSFpq2O0Kl4SKLReXk0IV2L4HuzvE7f6jFXrng== X-Received: by 2002:a17:90b:e83:b0:263:6114:f0f9 with SMTP id fv3-20020a17090b0e8300b002636114f0f9mr2649955pjb.42.1688148533406; Fri, 30 Jun 2023 11:08:53 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id 13-20020a17090a190d00b00256bedb4bedsm13678303pjg.52.2023.06.30.11.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 11:08:53 -0700 (PDT) Date: Fri, 30 Jun 2023 11:08:51 -0700 From: Stephen Hemminger To: "Min Hu (Connor)" Cc: , , , , , , , , , Subject: Re: [dpdk-dev] [PATCH 06/10] lib/librte_pipeline: fix the use of unsafe strcpy Message-ID: <20230630110851.491aa2aa@hermes.local> In-Reply-To: <1618839289-33224-7-git-send-email-humin29@huawei.com> References: <1618839289-33224-1-git-send-email-humin29@huawei.com> <1618839289-33224-7-git-send-email-humin29@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Mon, 19 Apr 2021 21:34:45 +0800 "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); > table->n_match_fields = t->n_fields; > table->n_actions = t->n_actions; > table->default_action_is_const = t->default_action_is_const; This patch is unnecessary. Both structures declare the same size for the name and args. Therefore the strcpy is always safe as long as the table structure is correctly setup with null terminated string. If not there are worse bugs.