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 A55A0C433FE for ; Tue, 26 Oct 2021 19:26:09 +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 BC78D60C49 for ; Tue, 26 Oct 2021 19:26:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BC78D60C49 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=konsulko.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 5C065833CB; Tue, 26 Oct 2021 21:26:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="jVxenqMT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4B747833B5; Tue, 26 Oct 2021 21:26:04 +0200 (CEST) Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7D04983323 for ; Tue, 26 Oct 2021 21:26:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x82c.google.com with SMTP id t16so272320qto.5 for ; Tue, 26 Oct 2021 12:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZoYwtoA1OIJBI3oFKvNdX7tYOTScJZ1P488JEI5KTnM=; b=jVxenqMTImYGC9aohxJ6ClpPM26gzHzGui1VP7RqQEGdzctCkTThLwNyjYyfn9gX/h DXd30G7v9sL3ZrNvU0a3x6Qu2aru0/75qGCLpdk4xnM6E9O3mRxvtRR14iIHlsbQnIc2 s0YejpoSGBEnq65s4oUZT3yXq2ZbEpd77WSjc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZoYwtoA1OIJBI3oFKvNdX7tYOTScJZ1P488JEI5KTnM=; b=IXp3V4vPhR0b0SM9rbVvWeQN9CC4NhzW0c36jAmPhNkkG1neTt3PRPf1I31+oo/bmG SfJ4+uSH0zfapW10MYKJnWh+phi/FwiT6HWkC0QKPrTiauseFdilB8Z4CIALVHiZFOQG QhNAzNd3GCNNeOCjZcX+HUE2142VHkGbrtuokZpZXMgKtK8RhVtwVIsigrS2M0kg46XH 4ZAtHBnoX1q+uu61hj9H+sGs2PV3eisMUv47OlIKqxAooXGei7v9hOs6jEz2U9oIvY6M Oc8Ymcwk+T5nj16QE3ou7lrD5zt+TzLBaPvUDrBqcFpEaQ58qwLrciEYQsx/ptp20lxX tWtQ== X-Gm-Message-State: AOAM531JVMCLNjPVr+h8yNcUhCaNTPIzmTTmQWSc0/Mvekq7QNMQ/ykD EAE/bsaPV5iGEEzFlH3CEzWydg== X-Google-Smtp-Source: ABdhPJw7Oi2dnuRpOokdxbzWlMHwzLDL/U6T8KG7JOaFlGLL5ZwwFjzFjuQWmTSZU2952D7h2DmBqw== X-Received: by 2002:a05:622a:28f:: with SMTP id z15mr4984660qtw.361.1635276359140; Tue, 26 Oct 2021 12:25:59 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b01-cbda-9d55-b872-362e-0c9f.res6.spectrum.com. [2603:6081:7b01:cbda:9d55:b872:362e:c9f]) by smtp.gmail.com with ESMTPSA id s23sm10896181qtx.63.2021.10.26.12.25.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 12:25:58 -0700 (PDT) Date: Tue, 26 Oct 2021 15:25:56 -0400 From: Tom Rini To: Jincheng Wang , Joao Marcos Costa , Thomas Petazzoni , Miquel Raynal Cc: u-boot@lists.denx.de Subject: Re: [PATCH1/1]sqfs: sqfs_tokenize() should fill the tokens list instead of free items Message-ID: <20211026192556.GA631424@bill-the-cat> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="6c2NcOVqGQ03X4Wi" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett 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 --6c2NcOVqGQ03X4Wi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Oct 16, 2021 at 10:19:48AM +0800, Jincheng Wang wrote: > We can delete two lines of code to avoid double free bug, but still a wild > 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]); > + /* fill tokens list to avoid wild pointers being freed*/ > + for (i =3D j + 1; i < count; i++) > + tokens[i] =3D 0; > ret =3D -ENOMEM; > goto free_strc; Aside from the whitespace having been destroyed, any comments from the maintainers / reviewers? Thanks! --=20 Tom --6c2NcOVqGQ03X4Wi Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmF4VkEACgkQFHw5/5Y0 tywsCgwAk+MnlJfTVjPMY0he/7Ja9+zpki+mVdP24OKjgiBb882+Yxm7SNVoEDrf ao1EIA3qGHWHAbgiRid5f3zdcNOFXyeKabt4dXW63IfQDWlcdRIU3NiVSWONXM7/ fOE9E5yd/Fmuu889sJwxWH2NMIXLhCrg2+iuD+fXCRjaglN6TMDjDpL+tf+x1KxU 2+6jM9bN/qr2aDT13/Mp4B6Ivr46lZiwFpbSz35Al81FIoOFQ7bBhXetjIbYC+JO 1p1vbMInqIBnov5pXBvCRhMqjrydSN3GWh/FoEVRqrw9Br4wM+ov2bX89FgA/1Rl vh5bfaCsQrH7E70f6cjEc0eAn0TFE8pwRSu3A+PdbCF3gpD7zPSfvBpEb/uLT8OW 4o/0wMrH6/SqLjpePVI1TZeqkEGhI0eOngRVQoUGjQeUiCDZ2vH+MtTJxxeBGR8j liYEK35wqCC4k8gQ32RtkPboDnvlrfg3vtG4r0vfohtb57DeApwH4Qrtdt4tw3FP qB+RAulh =PMl1 -----END PGP SIGNATURE----- --6c2NcOVqGQ03X4Wi--