From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id BCFAB107A for ; Thu, 14 Dec 2017 16:35:53 +0100 (CET) Received: from lfbn-lil-1-110-231.w90-45.abo.wanadoo.fr ([90.45.197.231] helo=droids-corp.org) by mail.droids-corp.org with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1ePVeE-0007iN-UD; Thu, 14 Dec 2017 16:42:12 +0100 Received: by droids-corp.org (sSMTP sendmail emulation); Thu, 14 Dec 2017 16:35:45 +0100 Date: Thu, 14 Dec 2017 16:35:45 +0100 From: Olivier MATZ To: Xueming Li Cc: Adrien Mazarguil , dev@dpdk.org Message-ID: <20171214153543.2d2ydissujk55cng@platinum> References: <20171115155402.9967-1-xuemingl@mellanox.com> <20171209153923.19958-1-xuemingl@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171209153923.19958-1-xuemingl@mellanox.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH v2] lib/cmdline: init CLI parsing memory 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: , X-List-Received-Date: Thu, 14 Dec 2017 15:35:53 -0000 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? Thanks, Olivier