tools/nolibc/stdlib: fix memory error in realloc()
authorBrennan Xavier McManus <bxmcmanus@gmail.com>
Tue, 9 Jan 2024 23:44:02 +0000 (18:44 -0500)
committerThomas Weißschuh <linux@weissschuh.net>
Wed, 10 Apr 2024 21:19:00 +0000 (23:19 +0200)
commit791f4641142e2aced85de082e5783b4fb0b977c2
treef7dd4a187b9adcfec8763e21c70fbcee0e81df50
parent4cece764965020c22cff7665b18a012006359095
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: Brennan Xavier McManus <bxmcmanus@gmail.com>
Cc: stable@vger.kernel.org
Reviewed-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Fixes: 0e0ff638400be8f497a35b51a4751fd823f6bd6a ("tools/nolibc/stdlib: Implement `malloc()`, `calloc()`, `realloc()` and `free()`")
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
tools/include/nolibc/stdlib.h