public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Andreas Schwab <schwab@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc] Missing ENOMEM in realloc_check wrapper (bug 27870) Date: Mon, 17 May 2021 19:40:48 +0000 (GMT) [thread overview] Message-ID: <20210517194048.828E03853809@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c6b6b4f2c7ff62abf5da617bff9d8080631993c0 commit c6b6b4f2c7ff62abf5da617bff9d8080631993c0 Author: Andreas Schwab <schwab@linux-m68k.org> Date: Mon May 17 14:00:19 2021 +0200 Missing ENOMEM in realloc_check wrapper (bug 27870) When MALLOC_CHECK_ is non-zero, the realloc hook missed to set errno to ENOMEM when called with too big size. Run the test tst-malloc-too-large also with MALLOC_CHECK_=3 to catch that. Diff: --- malloc/Makefile | 2 +- malloc/hooks.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/malloc/Makefile b/malloc/Makefile index afcd296ef6..857e2ebbd9 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -72,7 +72,7 @@ test-srcs = tst-mtrace # with MALLOC_CHECK_=3 because they expect a specific failure. tests-exclude-mcheck = tst-mcheck tst-malloc-usable \ tst-interpose-nothread tst-interpose-static-nothread \ - tst-interpose-static-thread tst-malloc-too-large \ + tst-interpose-static-thread \ tst-mxfast tst-safe-linking # Run all tests with MALLOC_CHECK_=3 diff --git a/malloc/hooks.c b/malloc/hooks.c index c91f9502ba..8080c3f40e 100644 --- a/malloc/hooks.c +++ b/malloc/hooks.c @@ -321,7 +321,10 @@ realloc_check (void *oldmem, size_t bytes, const void *caller) const INTERNAL_SIZE_T oldsize = chunksize (oldp); if (!checked_request2size (rb, &chnb)) - goto invert; + { + __set_errno (ENOMEM); + goto invert; + } __libc_lock_lock (main_arena.mutex);
reply other threads:[~2021-05-17 19:40 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=20210517194048.828E03853809@sourceware.org \ --to=schwab@sourceware.org \ --cc=glibc-cvs@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: linkBe 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).