public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Cyril Yared <yaredcyril@gmail.com>
To: newlib@sourceware.org
Subject: Null-pointer dereference bug in nano-malloc
Date: Mon, 24 Jan 2022 22:04:11 -0800	[thread overview]
Message-ID: <CAFq0=_MsCp0=AaHENtW=idrD4Z=PYX40ybJnyY85_qZ4urdN0g@mail.gmail.com> (raw)

Hi,
It appears that commit 84d068971 introduced a null-pointer dereference in
nano-malloc when the following two conditions are met:

1). The free_list has no items (= NULL).
2). The call to sbrk_aligned returns -1 (failure).

On line 325 of newlib/libc/stdlib/nano-mallocr.c, there is a check:

if ((char *)p + p->size == (char *)_SBRK_R(RCALL 0))
{

If the two conditions are met, then p = free_list = NULL so p->size will be
a null-pointer dereference. Is this something that's known/being tracked
anywhere?
Cyril

             reply	other threads:[~2022-01-25  6:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-25  6:04 Cyril Yared [this message]
2022-01-25 12:35 ` Corinna Vinschen

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='CAFq0=_MsCp0=AaHENtW=idrD4Z=PYX40ybJnyY85_qZ4urdN0g@mail.gmail.com' \
    --to=yaredcyril@gmail.com \
    --cc=newlib@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).