From: Dominic Chen <d.c.ddcc@gmail.com>
To: musl@lists.openwall.com
Subject: [musl] [PATCH] Fix crash in malloc_usable_size() if nullptr
Date: Wed, 25 Nov 2020 02:53:16 -0500 [thread overview]
Message-ID: <fad9eac5-622d-b317-70da-311f6cac3557@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 223 bytes --]
Please CC me on replies.
According to the manual for malloc_usable_size(), zero should be
returned if the input pointer is NULL. Currently, this is not checked,
which can result in SIGSEGV at runtime.
Thanks,
Dominic
[-- Attachment #2: patch.diff --]
[-- Type: text/plain, Size: 396 bytes --]
diff --git a/src/malloc/mallocng/malloc_usable_size.c b/src/malloc/mallocng/malloc_usable_size.c
index a440a4ea..ce6a960c 100644
--- a/src/malloc/mallocng/malloc_usable_size.c
+++ b/src/malloc/mallocng/malloc_usable_size.c
@@ -3,6 +3,7 @@
size_t malloc_usable_size(void *p)
{
+ if (!p) return 0;
struct meta *g = get_meta(p);
int idx = get_slot_index(p);
size_t stride = get_stride(g);
reply other threads:[~2020-11-25 7:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=fad9eac5-622d-b317-70da-311f6cac3557@gmail.com \
--to=d.c.ddcc@gmail.com \
--cc=musl@lists.openwall.com \
/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/musl/
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).