summaryrefslogtreecommitdiffstats
path: root/libc/include/sys
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2013-10-02 16:11:30 -0700
committerNick Kralevich <nnk@google.com>2013-10-02 16:11:30 -0700
commit90201d5eca050414d50a433866ccb580415bb0d4 (patch)
tree5d4f66ab3b47c32b1633eeb61d900223f79b0747 /libc/include/sys
parent32c0c6e7d56ea2fad0a362f37bb84937b82c3be2 (diff)
downloadbionic-90201d5eca050414d50a433866ccb580415bb0d4.zip
bionic-90201d5eca050414d50a433866ccb580415bb0d4.tar.gz
bionic-90201d5eca050414d50a433866ccb580415bb0d4.tar.bz2
FORTIFY_SOURCE: Add __FD_* checks
Add FORTIFY_SOURCE checks for the following macros: * FD_CLR * FD_ISSET * FD_SET Bug: 11047121 Change-Id: I3c5952136aec9eff3288b91b1318677ff971525c
Diffstat (limited to 'libc/include/sys')
-rw-r--r--libc/include/sys/select.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/libc/include/sys/select.h b/libc/include/sys/select.h
index 8d77957..c8cd8e1 100644
--- a/libc/include/sys/select.h
+++ b/libc/include/sys/select.h
@@ -46,14 +46,23 @@ typedef struct {
#define __FDELT(fd) ((fd) / __NFDBITS)
#define __FDMASK(fd) (1UL << ((fd) % __NFDBITS))
#define __FDS_BITS(set) (((fd_set*)(set))->fds_bits)
-
#define __FD_CLR(fd, set) (__FDS_BITS(set)[__FDELT(fd)] &= ~__FDMASK(fd))
#define __FD_SET(fd, set) (__FDS_BITS(set)[__FDELT(fd)] |= __FDMASK(fd))
-
#define __FD_ISSET(fd, set) ((__FDS_BITS(set)[__FDELT(fd)] & __FDMASK(fd)) != 0)
-
#define __FD_ZERO(set) (__builtin_memset(set, 0, sizeof(*(fd_set*)(set))))
+#if defined(__BIONIC_FORTIFY)
+extern void __FD_CLR_chk(int, fd_set*);
+extern void __FD_SET_chk(int, fd_set*);
+extern int __FD_ISSET_chk(int, fd_set*);
+#undef __FD_CLR
+#undef __FD_SET
+#undef __FD_ISSET
+#define __FD_CLR(fd, set) __FD_CLR_chk(fd, set)
+#define __FD_SET(fd, set) __FD_SET_chk(fd, set)
+#define __FD_ISSET(fd, set) __FD_ISSET_chk(fd, set)
+#endif /* defined(__BIONIC_FORTIFY) */
+
extern int select(int, fd_set*, fd_set*, fd_set*, struct timeval*);
extern int pselect(int n, fd_set* read_fds, fd_set* write_fds, fd_set* err_fds,
const struct timespec * timeout, const sigset_t* sigmask);