From 7279c33202a77972301aa367667de9207f360c1b Mon Sep 17 00:00:00 2001 From: sin Date: Tue, 3 Mar 2015 14:28:25 +0000 Subject: Add ppoll() check --- include/poll.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include') diff --git a/include/poll.h b/include/poll.h index 4eb2713..8810bca 100644 --- a/include/poll.h +++ b/include/poll.h @@ -16,9 +16,28 @@ __fortify_poll(struct pollfd *fds, nfds_t nfds, int timeout) return poll(fds, nfds, timeout); } +#ifdef _GNU_SOURCE +int +__fortify_ppoll(struct pollfd *fds, nfds_t nfds, + const struct timespec *timeout, const sigset_t *mask) +{ + __typeof__(sizeof 0) bos = __builtin_object_size(fds, 0); + + if (nfds > bos / sizeof(struct pollfd)) + __builtin_trap(); + return ppoll(fds, nfds, timeout, mask); +} + +#endif + #undef poll #define poll(fds, nfds, timeout) __fortify_poll(fds, nfds, timeout) +#ifdef _GNU_SOURCE +#undef ppoll +#define ppoll(fds, nfds, timeout, mask) __fortify_ppoll(fds, nfds, timeout, mask) +#endif + #endif #endif -- cgit v1.3