Fixup API level guards for new fortify functions.
Test: tools/update_headers.sh && make checkbuild Bug: None Change-Id: I9d06ea8a5ee9dc27d957f59e6e84150651ed1c76
This commit is contained in:
parent
8b154b1e82
commit
9c2094f3c5
|
@ -108,6 +108,7 @@ int __openat_real(int, const char*, int, ...) __RENAME(openat);
|
|||
#define __open_too_few_args_error "called with O_CREAT, but missing mode"
|
||||
#if defined(__clang__)
|
||||
|
||||
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
|
||||
__BIONIC_ERROR_FUNCTION_VISIBILITY
|
||||
int open(const char* pathname, int flags, mode_t modes, ...) __overloadable
|
||||
__errorattr(__open_too_many_args_error);
|
||||
|
@ -156,11 +157,13 @@ int openat(int dirfd, const char* const __pass_object_size pathname, int flags,
|
|||
mode_t modes) __overloadable {
|
||||
return __openat_real(dirfd, pathname, flags, modes);
|
||||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
|
||||
|
||||
#else /* defined(__clang__) */
|
||||
__errordecl(__creat_missing_mode, __open_too_few_args_error);
|
||||
__errordecl(__creat_too_many_args, __open_too_many_args_error);
|
||||
|
||||
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
|
||||
__BIONIC_FORTIFY_INLINE
|
||||
int open(const char* pathname, int flags, ...) {
|
||||
if (__builtin_constant_p(flags)) {
|
||||
|
@ -198,6 +201,7 @@ int openat(int dirfd, const char* pathname, int flags, ...) {
|
|||
|
||||
return __openat_real(dirfd, pathname, flags, __builtin_va_arg_pack());
|
||||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
|
||||
|
||||
#endif /* defined(__clang__) */
|
||||
|
||||
|
|
|
@ -379,6 +379,7 @@ size_t fwrite(const void * __restrict const __pass_object_size0 buf,
|
|||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
|
||||
|
||||
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
|
||||
__BIONIC_ERROR_FUNCTION_VISIBILITY
|
||||
char *fgets(char* __restrict dest, int size, FILE* stream) __overloadable
|
||||
__enable_if(size < 0, "size is negative")
|
||||
|
@ -401,6 +402,7 @@ char *fgets(char* __restrict const __pass_object_size dest,
|
|||
|
||||
return __fgets_chk(dest, size, stream, bos);
|
||||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
|
||||
|
||||
#else /* defined(__clang__) */
|
||||
|
||||
|
@ -482,6 +484,7 @@ size_t fwrite(const void * __restrict buf, size_t size, size_t count, FILE * __r
|
|||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
|
||||
|
||||
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
|
||||
__BIONIC_FORTIFY_INLINE
|
||||
char *fgets(char* dest, int size, FILE* stream) {
|
||||
size_t bos = __bos(dest);
|
||||
|
@ -511,6 +514,7 @@ char *fgets(char* dest, int size, FILE* stream) {
|
|||
|
||||
return __fgets_chk(dest, size, stream, bos);
|
||||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
|
||||
|
||||
#endif /* defined(__clang__) */
|
||||
#endif /* defined(__BIONIC_FORTIFY) */
|
||||
|
|
|
@ -194,7 +194,6 @@ char* strcpy(char* _Nonnull __restrict const dst __pass_object_size,
|
|||
const char* _Nonnull __restrict src) __overloadable {
|
||||
return __builtin___strcpy_chk(dst, src, __bos(dst));
|
||||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
|
||||
|
||||
__BIONIC_FORTIFY_INLINE
|
||||
char* strcat(char* _Nonnull __restrict const dst __pass_object_size,
|
||||
|
@ -213,6 +212,7 @@ void* memset(void* const _Nonnull s __pass_object_size0, int c, size_t n)
|
|||
__overloadable {
|
||||
return __builtin___memset_chk(s, c, n, __bos0(s));
|
||||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
|
||||
|
||||
|
||||
#if defined(__clang__)
|
||||
|
@ -287,9 +287,7 @@ char* stpncpy(char* __restrict const _Nonnull dst __pass_object_size,
|
|||
|
||||
return __stpncpy_chk2(dst, src, n, bos_dst, bos_src);
|
||||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */
|
||||
|
||||
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
|
||||
__BIONIC_FORTIFY_INLINE
|
||||
char* strncpy(char* __restrict const _Nonnull dst __pass_object_size,
|
||||
const char* __restrict const _Nonnull src __pass_object_size,
|
||||
|
@ -304,7 +302,9 @@ char* strncpy(char* __restrict const _Nonnull dst __pass_object_size,
|
|||
|
||||
return __strncpy_chk2(dst, src, n, bos_dst, bos_src);
|
||||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */
|
||||
|
||||
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
|
||||
__BIONIC_FORTIFY_INLINE
|
||||
size_t strlcpy(char* const _Nonnull __restrict dst __pass_object_size,
|
||||
const char *_Nonnull __restrict src, size_t size) __overloadable {
|
||||
|
@ -383,6 +383,7 @@ char* strrchr(const char* const _Nonnull s __pass_object_size, int c)
|
|||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR2__ */
|
||||
|
||||
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
|
||||
/* In *many* cases, memset(foo, sizeof(foo), 0) is a mistake where the user has
|
||||
* flipped the size + value arguments. However, there may be cases (e.g. with
|
||||
* macros) where it's okay for the size to fold to zero. We should warn on this,
|
||||
|
@ -412,6 +413,7 @@ void* memset(void* _Nonnull s, int c, size_t n) __overloadable
|
|||
__warnattr_real("will set 0 bytes; maybe the arguments got flipped? "
|
||||
"(Add __bionic_zero_size_is_okay as a fourth argument "
|
||||
"to silence this.)");
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
|
||||
|
||||
#undef __error_zero_size
|
||||
#undef __error_if_overflows_dst
|
||||
|
|
|
@ -403,6 +403,7 @@ ssize_t pwrite64(int fd, const void* const __pass_object_size0 buf,
|
|||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
|
||||
|
||||
#if __ANDROID_API__ >= __ANDROID_API_L__
|
||||
__BIONIC_ERROR_FUNCTION_VISIBILITY
|
||||
ssize_t read(int fd, void* buf, size_t count) __overloadable
|
||||
__error_if_overflows_ssizet(count);
|
||||
|
@ -423,7 +424,9 @@ ssize_t read(int fd, void* const __pass_object_size0 buf, size_t count)
|
|||
|
||||
return __read_chk(fd, buf, count, bos);
|
||||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */
|
||||
|
||||
#if __ANDROID_API__ >= __ANDROID_API_N__
|
||||
__BIONIC_ERROR_FUNCTION_VISIBILITY
|
||||
ssize_t write(int fd, const void* buf, size_t count) __overloadable
|
||||
__error_if_overflows_ssizet(count);
|
||||
|
@ -444,7 +447,9 @@ ssize_t write(int fd, const void* const __pass_object_size0 buf, size_t count)
|
|||
|
||||
return __write_chk(fd, buf, count, bos);
|
||||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
|
||||
|
||||
#if __ANDROID_API__ >= __ANDROID_API_M__
|
||||
__BIONIC_ERROR_FUNCTION_VISIBILITY
|
||||
ssize_t readlink(const char* path, char* buf, size_t size) __overloadable
|
||||
__error_if_overflows_ssizet(size);
|
||||
|
@ -466,7 +471,6 @@ ssize_t readlink(const char* path, char* const __pass_object_size buf,
|
|||
return __readlink_chk(path, buf, size, bos);
|
||||
}
|
||||
|
||||
|
||||
__BIONIC_ERROR_FUNCTION_VISIBILITY
|
||||
ssize_t readlinkat(int dirfd, const char* path, char* buf, size_t size)
|
||||
__overloadable
|
||||
|
@ -490,6 +494,7 @@ ssize_t readlinkat(int dirfd, const char* path,
|
|||
|
||||
return __readlinkat_chk(dirfd, path, buf, size, bos);
|
||||
}
|
||||
#endif /* __ANDROID_API__ >= __ANDROID_API_M__ */
|
||||
|
||||
#undef __enable_if_no_overflow_ssizet
|
||||
#undef __error_if_overflows_objectsize
|
||||
|
|
Loading…
Reference in New Issue