fortify-headers

standalone fortify-source implementation
git clone git://git.2f30.org/fortify-headers
Log | Files | Refs | README | LICENSE

commit 7279c33202a77972301aa367667de9207f360c1b
parent 15c2b9d8df9c4a2959abe5dee488f741f9aeb223
Author: sin <sin@2f30.org>
Date:   Tue,  3 Mar 2015 14:28:25 +0000

Add ppoll() check

Diffstat:
Minclude/poll.h | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git 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