fortify: inline #defined strings
These were originally #defined so we could share them between our GCC and clang FORTIFY implementations. Since we no longer have a GCC FORTIFY, #defining them is sort of pointless. Bug: 131861088 Test: mma Change-Id: I2ae4e0bdebbed16c946f5df7cc38c471881b481e
This commit is contained in:
parent
5273dc588a
commit
ff7179350a
3 changed files with 7 additions and 15 deletions
|
@ -37,14 +37,12 @@ ssize_t __recvfrom_chk(int, void*, size_t, size_t, int, struct sockaddr*,
|
|||
|
||||
#if defined(__BIONIC_FORTIFY)
|
||||
|
||||
#define __recvfrom_bad_size "'recvfrom' called with size bigger than buffer"
|
||||
#define __sendto_bad_size "'sendto' called with size bigger than buffer"
|
||||
|
||||
#if __ANDROID_API__ >= __ANDROID_API_N__
|
||||
__BIONIC_FORTIFY_INLINE
|
||||
ssize_t recvfrom(int fd, void* const buf __pass_object_size0, size_t len, int flags, struct sockaddr* src_addr, socklen_t* addr_len)
|
||||
__overloadable
|
||||
__clang_error_if(__bos_unevaluated_lt(__bos0(buf), len), __recvfrom_bad_size) {
|
||||
__clang_error_if(__bos_unevaluated_lt(__bos0(buf), len),
|
||||
"'recvfrom' called with size bigger than buffer") {
|
||||
size_t bos = __bos0(buf);
|
||||
|
||||
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
|
||||
|
@ -58,7 +56,8 @@ ssize_t recvfrom(int fd, void* const buf __pass_object_size0, size_t len, int fl
|
|||
__BIONIC_FORTIFY_INLINE
|
||||
ssize_t sendto(int fd, const void* const buf __pass_object_size0, size_t len, int flags, const struct sockaddr* dest_addr, socklen_t addr_len)
|
||||
__overloadable
|
||||
__clang_error_if(__bos_unevaluated_lt(__bos0(buf), len), __sendto_bad_size) {
|
||||
__clang_error_if(__bos_unevaluated_lt(__bos0(buf), len),
|
||||
"'sendto' called with size bigger than buffer") {
|
||||
size_t bos = __bos0(buf);
|
||||
|
||||
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
|
||||
|
@ -84,6 +83,4 @@ ssize_t send(int socket, const void* const buf __pass_object_size0, size_t len,
|
|||
return sendto(socket, buf, len, flags, NULL, 0);
|
||||
}
|
||||
|
||||
#undef __recvfrom_bad_size
|
||||
#undef __sendto_bad_size
|
||||
#endif /* __BIONIC_FORTIFY */
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
mode_t __umask_chk(mode_t) __INTRODUCED_IN(18);
|
||||
|
||||
#if defined(__BIONIC_FORTIFY)
|
||||
#define __umask_invalid_mode_str "'umask' called with invalid mode"
|
||||
|
||||
#if __ANDROID_API__ >= __ANDROID_API_J_MR2__
|
||||
/* Abuse enable_if to make this an overload of umask. */
|
||||
|
@ -41,11 +40,9 @@ __BIONIC_FORTIFY_INLINE
|
|||
mode_t umask(mode_t mode)
|
||||
__overloadable
|
||||
__enable_if(1, "")
|
||||
__clang_error_if(mode & ~0777, __umask_invalid_mode_str) {
|
||||
__clang_error_if(mode & ~0777, "'umask' called with invalid mode") {
|
||||
return __umask_chk(mode);
|
||||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR2__ */
|
||||
|
||||
#undef __umask_invalid_mode_str
|
||||
|
||||
#endif /* defined(__BIONIC_FORTIFY) */
|
||||
|
|
|
@ -31,18 +31,16 @@
|
|||
#endif
|
||||
|
||||
#if defined(__BIONIC_FORTIFY)
|
||||
#define __realpath_buf_too_small_str \
|
||||
"'realpath' output parameter must be NULL or a pointer to a buffer with >= PATH_MAX bytes"
|
||||
|
||||
/* PATH_MAX is unavailable without polluting the namespace, but it's always 4096 on Linux */
|
||||
#define __PATH_MAX 4096
|
||||
|
||||
char* realpath(const char* path, char* resolved)
|
||||
__clang_error_if(__bos_unevaluated_lt(__bos(resolved), __PATH_MAX),
|
||||
__realpath_buf_too_small_str)
|
||||
"'realpath' output parameter must be NULL or a pointer to a buffer "
|
||||
"with >= PATH_MAX bytes")
|
||||
__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. */
|
||||
|
||||
#undef __PATH_MAX
|
||||
#undef __realpath_buf_too_small_str
|
||||
#endif /* defined(__BIONIC_FORTIFY) */
|
||||
|
|
Loading…
Reference in a new issue