From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adrien Mazarguil Subject: Re: [PATCH v2] lib/cmdline: init CLI parsing memory Date: Mon, 18 Dec 2017 11:51:19 +0100 Message-ID: <20171218105119.GY4062@6wind.com> References: <20171115155402.9967-1-xuemingl@mellanox.com> <20171209153923.19958-1-xuemingl@mellanox.com> <20171214153543.2d2ydissujk55cng@platinum> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Xueming Li , dev@dpdk.org To: Olivier MATZ Return-path: Received: from mail-wr0-f172.google.com (mail-wr0-f172.google.com [209.85.128.172]) by dpdk.org (Postfix) with ESMTP id 7587716E for ; Mon, 18 Dec 2017 11:51:32 +0100 (CET) Received: by mail-wr0-f172.google.com with SMTP id o2so13611340wro.5 for ; Mon, 18 Dec 2017 02:51:32 -0800 (PST) Content-Disposition: inline In-Reply-To: <20171214153543.2d2ydissujk55cng@platinum> 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 Thu, Dec 14, 2017 at 04:35:45PM +0100, Olivier MATZ wrote: > Hi Xueming, > > On Sat, Dec 09, 2017 at 11:39:23PM +0800, Xueming Li wrote: > > Initialize result memory every time before parsing. Also save > > successfully parsed result before further ambiguous command detection to > > avoid result being tainted by later parsing. > > > > Signed-off-by: Xueming Li > > I'm ok with the content of the patch, but this has 2 be split in 2 > commits, which fixes different things. > > 1/ cmdline: fix dynamic tokens parsing > > [contains what Adrien suggested = all your patch but memset] > > When using dynamic tokens, the result buffer contains pointers > to some location inside the result buffer. When the content of > the temporary buffer is copied in the final one, these pointers > still point to the temporary buffer. > > This works until the temporary buffer is kept intact, but the > next commit introduces a memset() that breaks this assumption. > > This commit renames the buffers, and ensures that the pointers > point to the valid location, by recopying the buffer before > invoking f(). > > Fixes: 9b3fbb051d2e ("cmdline: fix parsing") > Cc: stable@dpdk.org > > > 2/ cmdline: avoid garbage in unused fields of parsed result > > [contains the memset() only] > > The result buffer was not initialized before parsing, inducing > garbage in unused fields or padding of the parsed structure. > > Initialize the result buffer each time before parsing. > > Fixes: af75078fece3 ("first public release") > Cc: stable@dpdk.org > > > Thoughts? > Adrien, are you also ok? Yes I fully agree, splitting this in two patches is also what I had in mind. Xueming, do you plan to submit v3 accordingly? -- Adrien Mazarguil 6WIND