2015-02-28 12:10:41 +00:00
|
|
|
#ifndef FORTIFY_POLL_H_
|
|
|
|
#define FORTIFY_POLL_H_
|
|
|
|
|
|
|
|
#include_next <poll.h>
|
|
|
|
|
|
|
|
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
|
|
|
|
|
2015-03-11 11:18:31 +00:00
|
|
|
#ifndef __cplusplus
|
2015-03-11 09:26:11 +00:00
|
|
|
|
2015-02-28 12:10:41 +00:00
|
|
|
static inline __attribute__ ((always_inline))
|
|
|
|
int
|
|
|
|
__fortify_poll(struct pollfd *fds, nfds_t nfds, int timeout)
|
|
|
|
{
|
2015-02-28 16:01:26 +00:00
|
|
|
__typeof__(sizeof 0) bos = __builtin_object_size(fds, 0);
|
2015-02-28 12:10:41 +00:00
|
|
|
|
2015-02-28 20:49:00 +00:00
|
|
|
if (nfds > bos / sizeof(struct pollfd))
|
2015-02-28 12:10:41 +00:00
|
|
|
__builtin_trap();
|
|
|
|
return poll(fds, nfds, timeout);
|
|
|
|
}
|
|
|
|
|
2015-03-03 14:28:25 +00:00
|
|
|
#ifdef _GNU_SOURCE
|
2015-03-10 18:04:21 +00:00
|
|
|
static inline __attribute__ ((always_inline))
|
|
|
|
int
|
2015-03-03 14:28:25 +00:00
|
|
|
__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
|
|
|
|
|
2015-02-28 12:10:41 +00:00
|
|
|
#undef poll
|
|
|
|
#define poll(fds, nfds, timeout) __fortify_poll(fds, nfds, timeout)
|
|
|
|
|
2015-03-03 14:28:25 +00:00
|
|
|
#ifdef _GNU_SOURCE
|
|
|
|
#undef ppoll
|
|
|
|
#define ppoll(fds, nfds, timeout, mask) __fortify_ppoll(fds, nfds, timeout, mask)
|
|
|
|
#endif
|
|
|
|
|
2015-03-11 09:26:11 +00:00
|
|
|
#endif
|
|
|
|
|
2015-02-28 12:10:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|