summaryrefslogtreecommitdiff
path: root/include/poll.h
diff options
context:
space:
mode:
authorsin2015-05-13 12:04:15 +0100
committersin2015-05-13 12:05:29 +0100
commit158782b3bb791eae3c97947944c7023452bfbc96 (patch)
treeb76e70744ab0a2f76d781a65a0456b1b010c54df /include/poll.h
parent316a48653315b4bc36d8c50b542471b18441c9d5 (diff)
Add fortify_fn() helper in fortify-headers.h
Diffstat (limited to 'include/poll.h')
-rw-r--r--include/poll.h14
1 files changed, 6 insertions, 8 deletions
diff --git a/include/poll.h b/include/poll.h
index d00d7c1..995f197 100644
--- a/include/poll.h
+++ b/include/poll.h
@@ -4,6 +4,7 @@
4#include_next <poll.h> 4#include_next <poll.h>
5 5
6#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 6#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
7#include "fortify-headers.h"
7 8
8#ifdef __cplusplus 9#ifdef __cplusplus
9extern "C" { 10extern "C" {
@@ -11,28 +12,25 @@ extern "C" {
11 12
12#undef poll 13#undef poll
13 14
14__typeof__(poll) __poll_orig __asm__(__USER_LABEL_PREFIX__ "poll"); 15fortify_fn(poll) int poll(struct pollfd *fds, nfds_t nfds, int timeout)
15extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
16int poll(struct pollfd *fds, nfds_t nfds, int timeout)
17{ 16{
18 __typeof__(sizeof 0) bos = __builtin_object_size(fds, 0); 17 __typeof__(sizeof 0) bos = __builtin_object_size(fds, 0);
19 18
20 if (nfds > bos / sizeof(struct pollfd)) 19 if (nfds > bos / sizeof(struct pollfd))
21 __builtin_trap(); 20 __builtin_trap();
22 return __poll_orig(fds, nfds, timeout); 21 return __orig_poll(fds, nfds, timeout);
23} 22}
24 23
25#ifdef _GNU_SOURCE 24#ifdef _GNU_SOURCE
26#undef ppoll 25#undef ppoll
27__typeof__(ppoll) __ppoll_orig __asm__(__USER_LABEL_PREFIX__ "ppoll"); 26fortify_fn(ppoll) int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
28extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__)) 27 const sigset_t *mask)
29int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const sigset_t *mask)
30{ 28{
31 __typeof__(sizeof 0) bos = __builtin_object_size(fds, 0); 29 __typeof__(sizeof 0) bos = __builtin_object_size(fds, 0);
32 30
33 if (nfds > bos / sizeof(struct pollfd)) 31 if (nfds > bos / sizeof(struct pollfd))
34 __builtin_trap(); 32 __builtin_trap();
35 return __ppoll_orig(fds, nfds, timeout, mask); 33 return __orig_ppoll(fds, nfds, timeout, mask);
36} 34}
37#endif 35#endif
38 36