public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Cyril Yared <yaredcyril@gmail.com>
To: newlib@sourceware.org
Cc: Cyril Yared <yaredcyril@gmail.com>
Subject: [PATCH 0/1] Fix null-pointer dereference in nano-malloc
Date: Tue, 25 Jan 2022 07:44:09 -0800	[thread overview]
Message-ID: <20220125154410.56045-1-yaredcyril@gmail.com> (raw)

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.

Cyril Yared (1):
  Fix a potential null-pointer dereference in nano-malloc when calling
    malloc() while the free_list is empty and the call to sbrk_aligned
    fails.

 newlib/libc/stdlib/nano-mallocr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.21.0 (Apple Git-122.2)


             reply	other threads:[~2022-01-25 15:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-25 15:44 Cyril Yared [this message]
2022-01-25 15:44 ` [PATCH 1/1] " Cyril Yared
2022-01-26 12:14   ` 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=20220125154410.56045-1-yaredcyril@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).