Add realpath() check
This commit is contained in:
parent
eecef18261
commit
f05c09fac8
|
@ -0,0 +1,35 @@
|
|||
#ifndef FORTIFY_STDLIB_H_
|
||||
#define FORTIFY_STDLIB_H_
|
||||
|
||||
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
|
||||
|| defined(_BSD_SOURCE)
|
||||
#include_next <limits.h>
|
||||
#endif
|
||||
|
||||
#include_next <stdlib.h>
|
||||
|
||||
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
|
||||
|
||||
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
|
||||
|| defined(_BSD_SOURCE)
|
||||
static inline __attribute__ ((always_inline))
|
||||
char *
|
||||
__fortify_realpath(const char *path, char *resolved)
|
||||
{
|
||||
size_t bos;
|
||||
|
||||
if (resolved) {
|
||||
bos = __builtin_object_size(resolved, 0);
|
||||
if (PATH_MAX > bos)
|
||||
__builtin_trap();
|
||||
}
|
||||
return realpath(path, resolved);
|
||||
}
|
||||
|
||||
#undef realpath
|
||||
#define realpath(path, resolved) __fortify_realpath(path, resolved)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue