fortify-headers

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

commit 7212959240ea8a73671d234c8b61ac81ca775b26
parent 4672406edd54ffe1466cdcb4b36c849e7245d603
Author: sin <sin@2f30.org>
Date:   Sat, 28 Feb 2015 16:01:26 +0000

Use __typeof__(sizeof 0) trickery

We cannot pull stddef.h and since fortify already relies on GCC
features we can use the above typeof trick to get a usable size_t.

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

diff --git a/include/poll.h b/include/poll.h @@ -9,9 +9,9 @@ static inline __attribute__ ((always_inline)) int __fortify_poll(struct pollfd *fds, nfds_t nfds, int timeout) { + __typeof__(sizeof 0) bos = __builtin_object_size(fds, 0); - if (__builtin_object_size(fds, 0) != -1 && - nfds > __builtin_object_size(fds, 0) / sizeof(struct pollfd)) + if (bos != -1 && nfds > bos / sizeof(struct pollfd)) __builtin_trap(); return poll(fds, nfds, timeout); }