From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Anton Moryakov <ant.v.moryakov@gmail.com>,
<linux-mtd@lists.infradead.org>
Subject: Re: [PATCH mtd-utils] ffsX-utils: Fix integer overflow in jffs2dump.c
Date: Mon, 16 Dec 2024 09:21:05 +0800 [thread overview]
Message-ID: <00adc50a-4233-4c7e-50ce-c05854dc6bee@huawei.com> (raw)
In-Reply-To: <20241214133453.102014-1-ant.v.moryakov@gmail.com>
在 2024/12/14 21:34, Anton Moryakov 写道:
> Report of the static analyzer:
> Pointer 'path', returned from function 'xstrdup' at jffs2reader.c:690, may be NULL and is dereferenced at jffs2reader.c:692.
>
> Corrections explained:
> After calling xstrdup(p), a path == NULL check has been added. This prevents a possible NULL pointer dereference in the event of a memory allocation error.
>
> Triggers found by static analyzer Svace.
>
> Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
>
> ---
> jffsX-utils/jffs2reader.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/jffsX-utils/jffs2reader.c b/jffsX-utils/jffs2reader.c
> index 87a2167..f776466 100644
> --- a/jffsX-utils/jffs2reader.c
> +++ b/jffsX-utils/jffs2reader.c
> @@ -694,6 +694,11 @@ static struct jffs2_raw_dirent *resolvepath0(char *o, size_t size, uint32_t ino,
>
> pp = path = xstrdup(p);
>
> + if(path == NULL){
> + *inos = 0;
> + return NULL;
> + }
> +
Hi Anton, please do some manual analysis before sending these patches
scanned by static analyzer. According to the realization of 'xstrdup()',
the program will exit if a failure memory allcation occurs.
> if (*path == '/') {
> path++;
> ino = 1;
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
prev parent reply other threads:[~2024-12-16 1:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-14 13:34 [PATCH mtd-utils] ffsX-utils: Fix integer overflow in jffs2dump.c Anton Moryakov
2024-12-16 1:21 ` Zhihao Cheng [this message]
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=00adc50a-4233-4c7e-50ce-c05854dc6bee@huawei.com \
--to=chengzhihao1@huawei.com \
--cc=ant.v.moryakov@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/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