From: Jun T <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: ZSH crashed when reading bytes from a large binary
Date: Mon, 12 Sep 2022 16:36:13 +0900 [thread overview]
Message-ID: <8F410818-257D-470A-B620-2F776E960ABC@kba.biglobe.ne.jp> (raw)
In-Reply-To: <SN6PR02MB4575B046FAF910E0AACD5903B3459@SN6PR02MB4575.namprd02.prod.outlook.com>
> 2022/09/11 23:43, Liu, Song <songliu@psu.edu> wrote:
>
> The problem is that, when ZSH failed to reallocate memory, ZSH didn’t check the return value of `realloc` function and handle the error. This will make ZSH crash.
>
> On line 6923 of `zsh/Src/builtin.c`, the correct code should like the following:
>
> ``` c
> If (buf = realloc(buf, bsiz *= 2)) {
> // same as previous code
> } else {
> free(buf);
> return EXIT_FAILURE;
> }
There are many other places where the return value of realloc() is not checked.
Can we simply replace them by zrealloc()?
next prev parent reply other threads:[~2022-09-12 7:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-11 14:43 Liu, Song
2022-09-12 7:36 ` Jun T [this message]
2022-09-14 21:43 ` Bart Schaefer
2022-09-15 10:19 ` Jun T
2022-09-15 10:41 ` Peter Stephenson
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=8F410818-257D-470A-B620-2F776E960ABC@kba.biglobe.ne.jp \
--to=takimoto-j@kba.biglobe.ne.jp \
--cc=zsh-workers@zsh.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).