diff options
author | Elliott Hughes <enh@google.com> | 2018-07-24 12:45:06 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-07-24 12:45:06 -0700 |
commit | f34903ed6f836dc496b819ca5e246ed8ac10138c (patch) | |
tree | 068475a0a85f6ed4919d4443fb39e7027e8485ed /libc/include/bits/fortify/stdlib.h | |
parent | 07a2606db934d1ecf6debe2332f713bb1feab615 (diff) | |
parent | 9e02e20878aaae4ea639246213af61378ccc728c (diff) |
Merge "Revert "Retire GCC FORTIFY."" am: 758051f058
am: 9e02e20878
Change-Id: I79064de26a6642b2ff5a788c8ccb50bf91c35ab7
Diffstat (limited to 'libc/include/bits/fortify/stdlib.h')
-rw-r--r-- | libc/include/bits/fortify/stdlib.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libc/include/bits/fortify/stdlib.h b/libc/include/bits/fortify/stdlib.h index d47c0b02a..8f3b02c9d 100644 --- a/libc/include/bits/fortify/stdlib.h +++ b/libc/include/bits/fortify/stdlib.h @@ -37,12 +37,31 @@ /* PATH_MAX is unavailable without polluting the namespace, but it's always 4096 on Linux */ #define __PATH_MAX 4096 +#if defined(__clang__) char* realpath(const char* path, char* resolved) __clang_error_if(__bos(resolved) != __BIONIC_FORTIFY_UNKNOWN_SIZE && __bos(resolved) < __PATH_MAX, __realpath_buf_too_small_str) __clang_error_if(!path, "'realpath': NULL path is never correct; flipped arguments?"); /* No need for a definition; the only issues we can catch are at compile-time. */ +#else /* defined(__clang__) */ + +char* __realpath_real(const char*, char*) __RENAME(realpath); +__errordecl(__realpath_size_error, __realpath_buf_too_small_str); + +__BIONIC_FORTIFY_INLINE +char* realpath(const char* path, char* resolved) { + size_t bos = __bos(resolved); + + if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE && bos < __PATH_MAX) { + __realpath_size_error(); + } + + return __realpath_real(path, resolved); +} + +#endif /* defined(__clang__) */ + #undef __PATH_MAX #undef __realpath_buf_too_small_str #endif /* defined(__BIONIC_FORTIFY) */ |