summaryrefslogtreecommitdiff
path: root/include/stdlib.h
diff options
context:
space:
mode:
authorjvoisin2023-03-18 14:01:02 +0100
committerjvoisin2025-10-31 22:16:21 +0100
commit249492e08adbf034976770ab3b021ba093a2ab18 (patch)
treecd04ae414fa7ef646a31f767b9295946fd2c9987 /include/stdlib.h
parente3fee64643279c144efd3d6856ed4e818c0d5ca2 (diff)
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.
Diffstat (limited to '')
-rw-r--r--include/stdlib.h4
1 files changed, 2 insertions, 2 deletions
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)
42#ifndef PATH_MAX 42#ifndef PATH_MAX
43#error PATH_MAX unset. A fortified realpath will not work. 43#error PATH_MAX unset. A fortified realpath will not work.
44#else 44#else
45 if (__r && PATH_MAX > __builtin_object_size(__r, 2)) { 45 if (__r && PATH_MAX > __bos(__r, 2)) {
46 char __buf[PATH_MAX], *__ret; 46 char __buf[PATH_MAX], *__ret;
47 size_t __l; 47 size_t __l;
48 48
@@ -50,7 +50,7 @@ _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r)
50 if (!__ret) 50 if (!__ret)
51 return NULL; 51 return NULL;
52 __l = __builtin_strlen(__ret) + 1; 52 __l = __builtin_strlen(__ret) + 1;
53 if (__l > __builtin_object_size(__r, 0)) 53 if (__l > __bos(__r, 0))
54 __builtin_trap(); 54 __builtin_trap();
55 __builtin_memcpy(__r, __ret, __l); 55 __builtin_memcpy(__r, __ret, __l);
56 return __r; 56 return __r;