mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
malloc: Abort on heap corruption, without a backtrace [BZ #21754]
The stack trace printing caused deadlocks and has been itself been targeted by code execution exploits.
This commit is contained in:
@ -1019,7 +1019,8 @@ static void* _int_realloc(mstate, mchunkptr, INTERNAL_SIZE_T,
|
||||
static void* _int_memalign(mstate, size_t, size_t);
|
||||
static void* _mid_memalign(size_t, size_t, void *);
|
||||
|
||||
static void malloc_printerr(int action, const char *str, void *ptr, mstate av);
|
||||
static void malloc_printerr(int action, const char *str, void *ptr, mstate av)
|
||||
__attribute__ ((noreturn));
|
||||
|
||||
static void* internal_function mem2mem_check(void *p, size_t sz);
|
||||
static int internal_function top_check(void);
|
||||
@ -5408,24 +5409,8 @@ malloc_printerr (int action, const char *str, void *ptr, mstate ar_ptr)
|
||||
if (ar_ptr)
|
||||
set_arena_corrupt (ar_ptr);
|
||||
|
||||
if ((action & 5) == 5)
|
||||
__libc_message ((action & 2) ? (do_abort | do_backtrace) : do_message,
|
||||
"%s\n", str);
|
||||
else if (action & 1)
|
||||
{
|
||||
char buf[2 * sizeof (uintptr_t) + 1];
|
||||
|
||||
buf[sizeof (buf) - 1] = '\0';
|
||||
char *cp = _itoa_word ((uintptr_t) ptr, &buf[sizeof (buf) - 1], 16, 0);
|
||||
while (cp > buf)
|
||||
*--cp = '0';
|
||||
|
||||
__libc_message ((action & 2) ? (do_abort | do_backtrace) : do_message,
|
||||
"*** Error in `%s': %s: 0x%s ***\n",
|
||||
__libc_argv[0] ? : "<unknown>", str, cp);
|
||||
}
|
||||
else if (action & 2)
|
||||
abort ();
|
||||
__libc_message (do_abort, "%s\n", str);
|
||||
__builtin_unreachable ();
|
||||
}
|
||||
|
||||
/* We need a wrapper function for one of the additions of POSIX. */
|
||||
|
Reference in New Issue
Block a user