From 9f8c543dc81f0c4239acae6713f5414eb7dc681d Mon Sep 17 00:00:00 2001 From: sin Date: Fri, 13 Mar 2015 11:00:46 +0000 Subject: Rework fortify implementation to use extern inline Overriding functions with macros is legal in C but a lot of software is not prepared for it. Use the extern inline method to achieve the same result. --- include/stdlib.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'include/stdlib.h') diff --git a/include/stdlib.h b/include/stdlib.h index 4aff9d9..f4a026b 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -12,9 +12,11 @@ #ifndef __cplusplus #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -static inline __attribute__ ((always_inline)) -char * -__fortify_realpath(const char *path, char *resolved) +#undef realpath +extern char *__realpath_orig(const char *, char *) + __asm__(__USER_LABEL_PREFIX__ "realpath"); +extern __inline __attribute__((__always_inline__,__gnu_inline__)) +char *realpath(const char *path, char *resolved) { size_t bos; @@ -27,11 +29,8 @@ __fortify_realpath(const char *path, char *resolved) __builtin_trap(); #endif } - return realpath(path, resolved); + return __realpath_orig(path, resolved); } - -#undef realpath -#define realpath(path, resolved) __fortify_realpath(path, resolved) #endif #endif -- cgit v1.3