public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: Jincheng Wang <jc.w4ng@gmail.com>,
	Joao Marcos Costa <joaomarcos.costa@bootlin.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH1/1]sqfs: sqfs_tokenize() should fill the tokens list instead of free items
Date: Tue, 26 Oct 2021 15:25:56 -0400	[thread overview]
Message-ID: <20211026192556.GA631424@bill-the-cat> (raw)
In-Reply-To: <CALO=DHH-Jn17DQ=UqXiKmpW+2svKVeadYUP6haATcNvP3Y19xg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1114 bytes --]

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.
> 
> A test for wild pointers:
>     sqfsls host 0  1//2/3//4/5
> 
> Fill the tokens list can solve it well.
> 
> 
> Signed-off-by: Jincheng Wang <jc.w4ng@gmail.com>
> ---
>  fs/squashfs/sqfs.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
>   }
> 
> 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 = strtok(!j ? strc : NULL, "/");
>   tokens[j] = strdup(aux);
>   if (!tokens[j]) {
> - for (i = 0; i < j; i++)
> - free(tokens[i]);
> + /* fill tokens list to avoid wild pointers being freed*/
> + for (i = j + 1; i < count; i++)
> + tokens[i] = 0;
>   ret = -ENOMEM;
>   goto free_strc;

Aside from the whitespace having been destroyed, any comments from the
maintainers / reviewers?  Thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

  reply	other threads:[~2021-10-26 19:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-16  2:19 [PATCH1/1]sqfs: sqfs_tokenize() should fill the tokens list instead of free items Jincheng Wang
2021-10-26 19:25 ` Tom Rini [this message]
2021-10-27  8:17   ` Miquel Raynal
     [not found]     ` <CALO=DHHq4hSsrAUorgxeTGOFh_HjTr00vFaGVEVQytvNiLiEJA@mail.gmail.com>
2021-10-31 10:24       ` Fwd: " Jincheng Wang
2021-11-02  7:11         ` Miquel Raynal
  -- strict thread matches above, loose matches on Subject: below --
2021-11-02  9:13 jc.w4ng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211026192556.GA631424@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=jc.w4ng@gmail.com \
    --cc=joaomarcos.costa@bootlin.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox