* [PATCH] Missing ENOMEM in realloc_check wrapper (bug 27870)
@ 2021-05-17 12:07 Andreas Schwab
2021-05-17 18:50 ` DJ Delorie
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Schwab @ 2021-05-17 12:07 UTC (permalink / raw)
To: libc-alpha
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.
---
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);
--
2.31.1
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Missing ENOMEM in realloc_check wrapper (bug 27870)
2021-05-17 12:07 [PATCH] Missing ENOMEM in realloc_check wrapper (bug 27870) Andreas Schwab
@ 2021-05-17 18:50 ` DJ Delorie
0 siblings, 0 replies; 2+ messages in thread
From: DJ Delorie @ 2021-05-17 18:50 UTC (permalink / raw)
To: Andreas Schwab; +Cc: libc-alpha
Andreas Schwab <schwab@linux-m68k.org> writes:
> 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.
LGTM.
Reviewed-by: DJ Delorie <dj@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-17 18:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 12:07 [PATCH] Missing ENOMEM in realloc_check wrapper (bug 27870) Andreas Schwab
2021-05-17 18:50 ` DJ Delorie
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).