Commit 791f4641 authored by Brennan Xavier McManus's avatar Brennan Xavier McManus Committed by Thomas Weißschuh

tools/nolibc/stdlib: fix memory error in realloc()

Pass user_p_len to memcpy() instead of heap->len to prevent realloc()
from copying an extra sizeof(heap) bytes from beyond the allocated
region.
Signed-off-by: default avatarBrennan Xavier McManus <bxmcmanus@gmail.com>
Cc: stable@vger.kernel.org
Reviewed-by: default avatarAmmar Faizi <ammarfaizi2@gnuweeb.org>
Fixes: 0e0ff638 ("tools/nolibc/stdlib: Implement `malloc()`, `calloc()`, `realloc()` and `free()`")
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
Signed-off-by: default avatarThomas Weißschuh <linux@weissschuh.net>
parent 4cece764
......@@ -185,7 +185,7 @@ void *realloc(void *old_ptr, size_t new_size)
if (__builtin_expect(!ret, 0))
return NULL;
memcpy(ret, heap->user_p, heap->len);
memcpy(ret, heap->user_p, user_p_len);
munmap(heap, heap->len);
return ret;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment