From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04DDDC433EF for ; Wed, 27 Oct 2021 08:17:20 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF6AE608FE for ; Wed, 27 Oct 2021 08:17:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CF6AE608FE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4C4A583230; Wed, 27 Oct 2021 10:17:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id BDCAE83297; Wed, 27 Oct 2021 10:17:14 +0200 (CEST) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 56F5582FE7 for ; Wed, 27 Oct 2021 10:17:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=miquel.raynal@bootlin.com Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 5CD63240005; Wed, 27 Oct 2021 08:17:10 +0000 (UTC) Date: Wed, 27 Oct 2021 10:17:09 +0200 From: Miquel Raynal To: Tom Rini Cc: Jincheng Wang , Joao Marcos Costa , Thomas Petazzoni , u-boot@lists.denx.de Subject: Re: [PATCH1/1]sqfs: sqfs_tokenize() should fill the tokens list instead of free items Message-ID: <20211027101709.5b494100@xps13> In-Reply-To: <20211026192556.GA631424@bill-the-cat> References: <20211026192556.GA631424@bill-the-cat> Organization: Bootlin X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hello, trini@konsulko.com wrote on Tue, 26 Oct 2021 15:25:56 -0400: > On Sat, Oct 16, 2021 at 10:19:48AM +0800, Jincheng Wang wrote: >=20 > > We can delete two lines of code to avoid double free bug, but still a w= ild > > pointers bug. > >=20 > > A test for wild pointers: > > sqfsls host 0 1//2/3//4/5 > >=20 > > Fill the tokens list can solve it well. > >=20 > >=20 > > Signed-off-by: Jincheng Wang > > --- > > fs/squashfs/sqfs.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > >=20 > > } > >=20 > > diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c > > index e2d91c654c..50d3f8b71e 100644 > > --- a/fs/squashfs/sqfs.c > > +++ b/fs/squashfs/sqfs.c > > @@ -303,8 +303,9 @@ static int sqfs_tokenize(char **tokens, int count, > > const char *str) > > aux =3D strtok(!j ? strc : NULL, "/"); > > tokens[j] =3D strdup(aux); > > if (!tokens[j]) { > > - for (i =3D 0; i < j; i++) > > - free(tokens[i]); Where is the double free here? Why do you stop freeing the tokens list? > > + /* fill tokens list to avoid wild pointers being freed*/ > > + for (i =3D j + 1; i < count; i++) > > + tokens[i] =3D 0; This does not feel right. Perhaps it's just me not getting through the lack of spacing successfully but this deserves more explanations. > > ret =3D -ENOMEM; > > goto free_strc; =20 >=20 > Aside from the whitespace having been destroyed, any comments from the > maintainers / reviewers? Thanks! >=20 Thanks, Miqu=C3=A8l