summaryrefslogtreecommitdiff
path: root/include/poll.h
blob: cbc78fd743e9599022ec38d9d5e97f7249ac3264 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef FORTIFY_POLL_H_
#define FORTIFY_POLL_H_

#include_next <poll.h>

#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0

static inline __attribute__ ((always_inline))
int
__fortify_poll(struct pollfd *fds, nfds_t nfds, int timeout)
{

	if (__builtin_object_size(fds, 0) != -1 &&
	    nfds > __builtin_object_size(fds, 0) / sizeof(struct pollfd))
		__builtin_trap();
	return poll(fds, nfds, timeout);
}

#undef poll
#define poll(fds, nfds, timeout) __fortify_poll(fds, nfds, timeout)

#endif

#endif