Merge "Guard fortify inlines with __ANDROID_API__."

This commit is contained in:
Treehugger Robot 2016-08-06 01:31:18 +00:00 committed by Gerrit Code Review
commit 4b10751310
6 changed files with 35 additions and 1 deletions

View file

@ -53,6 +53,7 @@ __errordecl(__ppoll_too_small_error, "ppoll: pollfd array smaller than fd count"
#if defined(__BIONIC_FORTIFY)
#if __ANDROID_API__ >= 23
__BIONIC_FORTIFY_INLINE
int poll(struct pollfd* fds, nfds_t fd_count, int timeout) {
#if defined(__clang__)
@ -84,6 +85,7 @@ int ppoll(struct pollfd* fds, nfds_t fd_count, const struct timespec* timeout, c
return __ppoll_real(fds, fd_count, timeout, mask);
#endif
}
#endif /* __ANDROID_API__ >= 23 */
#endif

View file

@ -266,6 +266,7 @@ __errordecl(__fwrite_overflow, "fwrite called with overflowing size * count");
#if defined(__BIONIC_FORTIFY)
#if __ANDROID_API__ >= 17
__BIONIC_FORTIFY_INLINE
__printflike(3, 0) int vsnprintf(char* dest, size_t size, const char* _Nonnull format, __va_list ap) {
return __builtin___vsnprintf_chk(dest, size, 0, __bos(dest), format, ap);
@ -299,7 +300,9 @@ __printflike(2, 3) int sprintf(char* dest, const char* _Nonnull format, ...) {
return __builtin___sprintf_chk(dest, 0, __bos(dest), format, __builtin_va_arg_pack());
}
#endif
#endif /* __ANDROID_API__ >= 17 */
#if __ANDROID_API__ >= 24
__BIONIC_FORTIFY_INLINE
size_t fread(void * __restrict buf, size_t size, size_t count, FILE * __restrict stream) {
size_t bos = __bos0(buf);
@ -351,6 +354,7 @@ size_t fwrite(const void * __restrict buf, size_t size, size_t count, FILE * __r
return __fwrite_chk(buf, size, count, stream, bos);
}
#endif /* __ANDROID_API__ >= 24 */
#if !defined(__clang__)

View file

@ -148,6 +148,7 @@ size_t __strlcat_chk(char* _Nonnull __restrict, const char* _Nonnull __restrict,
#if defined(__BIONIC_FORTIFY)
#if __ANDROID_API__ >= 23
__BIONIC_FORTIFY_INLINE
void* memchr(const void* s, int c, size_t n) {
size_t bos = __bos(s);
@ -189,7 +190,9 @@ void* memrchr(const void* s, int c, size_t n) {
return __memrchr_chk(s, c, n, bos);
}
#endif /* __ANDROID_API__ >= 23 */
#if __ANDROID_API__ >= 17
__BIONIC_FORTIFY_INLINE
void* memcpy(void* _Nonnull __restrict dst, const void* _Nonnull __restrict src, size_t copy_amount) {
return __builtin___memcpy_chk(dst, src, copy_amount, __bos0(dst));
@ -199,17 +202,23 @@ __BIONIC_FORTIFY_INLINE
void* memmove(void* _Nonnull dst, const void* _Nonnull src, size_t len) {
return __builtin___memmove_chk(dst, src, len, __bos0(dst));
}
#endif /* __ANDROID_API__ >= 17 */
#if __ANDROID_API__ >= 21
__BIONIC_FORTIFY_INLINE
char* stpcpy(char* _Nonnull __restrict dst, const char* _Nonnull __restrict src) {
return __builtin___stpcpy_chk(dst, src, __bos(dst));
}
#endif /* __ANDROID_API__ >= 21 */
#if __ANDROID_API__ >= 17
__BIONIC_FORTIFY_INLINE
char* strcpy(char* _Nonnull __restrict dst, const char* _Nonnull __restrict src) {
return __builtin___strcpy_chk(dst, src, __bos(dst));
}
#endif /* __ANDROID_API__ >= 17 */
#if __ANDROID_API__ >= 21
__BIONIC_FORTIFY_INLINE
char* stpncpy(char* _Nonnull __restrict dst, const char* _Nonnull __restrict src, size_t n) {
size_t bos_dst = __bos(dst);
@ -230,7 +239,9 @@ char* stpncpy(char* _Nonnull __restrict dst, const char* _Nonnull __restrict src
return __stpncpy_chk2(dst, src, n, bos_dst, bos_src);
}
#endif /* __ANDROID_API__ >= 21 */
#if __ANDROID_API__ >= 17
__BIONIC_FORTIFY_INLINE
char* strncpy(char* _Nonnull __restrict dst, const char* _Nonnull __restrict src, size_t n) {
size_t bos_dst = __bos(dst);
@ -326,7 +337,9 @@ size_t strlen(const char* _Nonnull s) {
return __strlen_chk(s, bos);
}
#endif /* __ANDROID_API__ >= 17 */
#if __ANDROID_API__ >= 18
__BIONIC_FORTIFY_INLINE
char* strchr(const char* _Nonnull s, int c) {
size_t bos = __bos(s);
@ -364,7 +377,7 @@ char* strrchr(const char* _Nonnull s, int c) {
return __strrchr_chk(s, c, bos);
}
#endif /* __ANDROID_API__ >= 18 */
#endif /* defined(__BIONIC_FORTIFY) */

View file

@ -300,6 +300,7 @@ ssize_t __recvfrom_real(int, void*, size_t, int, const struct sockaddr*, socklen
#if defined(__BIONIC_FORTIFY)
#if __ANDROID_API__ >= 24
__BIONIC_FORTIFY_INLINE
ssize_t recvfrom(int fd, void* buf, size_t len, int flags, const struct sockaddr* src_addr, socklen_t* addr_len) {
size_t bos = __bos0(buf);
@ -320,6 +321,7 @@ ssize_t recvfrom(int fd, void* buf, size_t len, int flags, const struct sockaddr
return __recvfrom_chk(fd, buf, len, bos, flags, src_addr, addr_len);
}
#endif /* __ANDROID_API__ >= 24 */
__BIONIC_FORTIFY_INLINE
ssize_t recv(int socket, void* buf, size_t len, int flags) {

View file

@ -163,6 +163,7 @@ __errordecl(__umask_invalid_mode, "umask called with invalid mode");
#if defined(__BIONIC_FORTIFY)
#if __ANDROID_API__ >= 18
__BIONIC_FORTIFY_INLINE
mode_t umask(mode_t mode) {
#if !defined(__clang__)
@ -175,6 +176,8 @@ mode_t umask(mode_t mode) {
#endif
return __umask_chk(mode);
}
#endif /* __ANDROID_API__ >= 18 */
#endif /* defined(__BIONIC_FORTIFY) */
#if __ANDROID_API__ >= 21

View file

@ -286,6 +286,7 @@ int setdomainname(const char*, size_t) __INTRODUCED_IN_FUTURE;
#if defined(__BIONIC_FORTIFY)
#if __ANDROID_API__ >= 24
__BIONIC_FORTIFY_INLINE
char* getcwd(char* buf, size_t size) {
size_t bos = __bos(buf);
@ -316,6 +317,7 @@ char* getcwd(char* buf, size_t size) {
return __getcwd_chk(buf, size, bos);
}
#endif /* __ANDROID_API__ >= 24 */
#if defined(__USE_FILE_OFFSET64)
#define __PREAD_PREFIX(x) __pread64_ ## x
@ -323,6 +325,7 @@ char* getcwd(char* buf, size_t size) {
#define __PREAD_PREFIX(x) __pread_ ## x
#endif
#if __ANDROID_API__ >= 23
__BIONIC_FORTIFY_INLINE
ssize_t pread(int fd, void* buf, size_t count, off_t offset) {
size_t bos = __bos0(buf);
@ -372,6 +375,7 @@ ssize_t pread64(int fd, void* buf, size_t count, off64_t offset) {
return __pread64_chk(fd, buf, count, offset, bos);
}
#endif /* __ANDROID_API__ >= 23 */
#if defined(__USE_FILE_OFFSET64)
#define __PWRITE_PREFIX(x) __pwrite64_ ## x
@ -379,6 +383,7 @@ ssize_t pread64(int fd, void* buf, size_t count, off64_t offset) {
#define __PWRITE_PREFIX(x) __pwrite_ ## x
#endif
#if __ANDROID_API__ >= 24
__BIONIC_FORTIFY_INLINE
ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset) {
size_t bos = __bos0(buf);
@ -428,7 +433,9 @@ ssize_t pwrite64(int fd, const void* buf, size_t count, off64_t offset) {
return __pwrite64_chk(fd, buf, count, offset, bos);
}
#endif /* __ANDROID_API__ >= 24 */
#if __ANDROID_API__ >= 21
__BIONIC_FORTIFY_INLINE
ssize_t read(int fd, void* buf, size_t count) {
size_t bos = __bos0(buf);
@ -453,7 +460,9 @@ ssize_t read(int fd, void* buf, size_t count) {
return __read_chk(fd, buf, count, bos);
}
#endif /* __ANDROID_API__ >= 21 */
#if __ANDROID_API__ >= 24
__BIONIC_FORTIFY_INLINE
ssize_t write(int fd, const void* buf, size_t count) {
size_t bos = __bos0(buf);
@ -480,6 +489,7 @@ ssize_t write(int fd, const void* buf, size_t count) {
return __write_chk(fd, buf, count, bos);
}
#endif /* __ANDROID_API__ >= 24 */
__BIONIC_FORTIFY_INLINE
ssize_t readlink(const char* path, char* buf, size_t size) {