From 9aa4490263ead62dc545cf0e8b83e0ef77eb7a6e Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 18 Jul 2023 23:07:05 +0200 Subject: Make use of the alloc_size attribute --- include/stdlib.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include/stdlib.h') diff --git a/include/stdlib.h b/include/stdlib.h index b661862..6914f02 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -37,13 +37,36 @@ extern "C" { #endif #undef malloc +#undef realloc __malloc(malloc (free, 1)) +__alloc_size(1) _FORTIFY_FN(malloc) void *malloc(size_t __s) { return __orig_malloc(__s); } +__alloc_size(2) +_FORTIFY_FN(realloc) void *realloc(void *__p, size_t __s) +{ + return __orig_realloc(__p, __s); +} + +__alloc_size(1, 2) +_FORTIFY_FN(calloc) void *calloc(size_t __n, size_t __s) +{ + return __orig_calloc(__n, __s); +} + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#undef reallocarray +__alloc_size (2, 3) +_FORTIFY_FN(reallocarray) void* reallocarray(void* __p, size_t __n, size_t __s) +{ + return __orig_reallocarray(__p, __n, __s); +} +#endif + /* FIXME clang */ #if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__) #undef realpath -- cgit v1.3