From: Miquel Raynal <miquel.raynal@bootlin.com>
To: u-boot@lists.denx.de
Subject: [PATCH] fs: squasfs: fix a possible NULL pointer dereference in sqfs_opendir()
Date: Mon, 21 Dec 2020 16:29:19 +0100 [thread overview]
Message-ID: <20201221162919.2133c37f@xps13> (raw)
In-Reply-To: <eb2d8cbc-17bd-b318-0e07-f2bca5d78e42@posteo.net>
Hi Richard,
Richard Genoud <richard.genoud@posteo.net> wrote on Mon, 21 Dec 2020
16:26:00 +0100:
> Le 21/12/2020 ? 16:14, Miquel Raynal a ?crit?:
> > Hi Richard,
> >
> > Richard Genoud <richard.genoud@posteo.net> wrote on Mon, 21 Dec 2020
> > 16:06:37 +0100:
> >
> >> Hi Miquel,
> >>
> >> Le 18/12/2020 ? 19:50, Miquel Raynal a ?crit?:
> >>> Hi Richard,
> >>>
> >>> Richard Genoud <richard.genoud@posteo.net> wrote on Fri, 18 Dec 2020
> >>> 15:24:40 +0100:
> >>> >>>> token_count may be != 0 and token_list not yet allocated when the out
> >>>> code is reached
> >>>
> >>> Wouldn't it be better to initialize token_count than adding an
> >>> (obscure) indentation level?
> >> Well, token_count is initialized :
> >> token_count = sqfs_count_tokens(filename);
> >>
> >> But token_list is not yet populated. It is some lines bellow:
> >> token_list = malloc(token_count * sizeof(char *));
> >>
> >>
> >> But I could use something like that, maybe it's clearer :
> >> for (j = 0; (token_list != NULL) && (j < token_count); j++)
> >> free(token_list[j]);
> >
> > I had a look at the code, the error path is clearly not correctly
> > organized.
> >
> > I think the right approach would be to have real labels like,
> > free_token_list, free_this, free_that and for each of them only do the
> > right cleanup. Doing so should fix the issue.
>
> So you're suggesting to revert this ?
> commit ea1b1651c6a8 ("fs/squashfs: sqfs_opendir: simplify error handling")
Yes (our e-mails crossed each other), I think it's best to have a well
organized error path. Of course this error path is maybe faulty, in
this case it must be fixed. But I personally prefer the revert + fix
approach.
Thanks,
Miqu?l
next prev parent reply other threads:[~2020-12-21 15:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-18 14:24 [PATCH] fs: squasfs: fix a possible NULL pointer dereference in sqfs_opendir() Richard Genoud
2020-12-18 18:50 ` Miquel Raynal
2020-12-21 15:06 ` Richard Genoud
2020-12-21 15:14 ` Miquel Raynal
2020-12-21 15:26 ` Richard Genoud
2020-12-21 15:29 ` Miquel Raynal [this message]
2020-12-21 15:40 ` Richard Genoud
2020-12-21 15:49 ` Miquel Raynal
2020-12-21 16:17 ` Richard Genoud
2020-12-22 7:46 ` Miquel Raynal
2020-12-22 9:07 ` Richard Genoud
2020-12-21 15:26 ` Miquel Raynal
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=20201221162919.2133c37f@xps13 \
--to=miquel.raynal@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