2015-02-24 19:04:02 +00:00
|
|
|
#ifndef FORTIFY_STDLIB_H_
|
|
|
|
#define FORTIFY_STDLIB_H_
|
|
|
|
|
2015-02-28 16:11:32 +00:00
|
|
|
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
2015-02-24 19:04:02 +00:00
|
|
|
#include_next <limits.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include_next <stdlib.h>
|
|
|
|
|
|
|
|
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
|
|
|
|
|
2015-03-11 09:26:11 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-02-28 16:11:32 +00:00
|
|
|
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
2015-02-24 19:04:02 +00:00
|
|
|
static inline __attribute__ ((always_inline))
|
|
|
|
char *
|
|
|
|
__fortify_realpath(const char *path, char *resolved)
|
|
|
|
{
|
|
|
|
size_t bos;
|
|
|
|
|
|
|
|
if (resolved) {
|
2015-02-28 15:59:27 +00:00
|
|
|
#ifndef PATH_MAX
|
|
|
|
__builtin_trap();
|
|
|
|
#else
|
2015-02-24 19:04:02 +00:00
|
|
|
bos = __builtin_object_size(resolved, 0);
|
|
|
|
if (PATH_MAX > bos)
|
|
|
|
__builtin_trap();
|
2015-02-28 15:59:27 +00:00
|
|
|
#endif
|
2015-02-24 19:04:02 +00:00
|
|
|
}
|
|
|
|
return realpath(path, resolved);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef realpath
|
|
|
|
#define realpath(path, resolved) __fortify_realpath(path, resolved)
|
|
|
|
#endif
|
|
|
|
|
2015-03-11 09:26:11 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-02-24 19:04:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|