From 3e6704d0be707487d7a9dccfdc75203c7261e11b Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 18 Mar 2023 14:01:02 +0100 Subject: Make use of __builtin_dynamic_object_size GCC and Clang provide __builtin_dynamic_object_size (see documentation: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html), so we should make use of it when its available. --- include/stdlib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/stdlib.h') diff --git a/include/stdlib.h b/include/stdlib.h index 11155cf..8642e83 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -42,7 +42,7 @@ _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) #ifndef PATH_MAX #error PATH_MAX unset. A fortified realpath will not work. #else - if (__r && PATH_MAX > __builtin_object_size(__r, 2)) { + if (__r && PATH_MAX > __bos(__r, 2)) { char __buf[PATH_MAX], *__ret; size_t __l; @@ -50,7 +50,7 @@ _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) if (!__ret) return NULL; __l = __builtin_strlen(__ret) + 1; - if (__l > __builtin_object_size(__r, 0)) + if (__l > __bos(__r, 0)) __builtin_trap(); __builtin_memcpy(__r, __ret, __l); return __r; -- cgit v1.3