2015-05-13 11:15:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Dimitris Papastamos <sin@2f30.org>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2015-03-11 18:55:51 +00:00
|
|
|
#ifndef _FORTIFY_POLL_H
|
|
|
|
#define _FORTIFY_POLL_H
|
2015-02-28 12:10:41 +00:00
|
|
|
|
|
|
|
#include_next <poll.h>
|
|
|
|
|
|
|
|
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
|
2015-05-13 11:04:15 +00:00
|
|
|
#include "fortify-headers.h"
|
2015-02-28 12:10:41 +00:00
|
|
|
|
2015-03-13 23:09:15 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-03-13 11:00:46 +00:00
|
|
|
#undef poll
|
2015-03-11 09:26:11 +00:00
|
|
|
|
2015-05-13 11:04:15 +00:00
|
|
|
fortify_fn(poll) int poll(struct pollfd *fds, nfds_t nfds, int timeout)
|
2015-02-28 12:10:41 +00:00
|
|
|
{
|
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();
|
2015-05-13 11:04:15 +00:00
|
|
|
return __orig_poll(fds, nfds, timeout);
|
2015-02-28 12:10:41 +00:00
|
|
|
}
|
|
|
|
|
2015-03-03 14:28:25 +00:00
|
|
|
#ifdef _GNU_SOURCE
|
2015-03-13 11:00:46 +00:00
|
|
|
#undef ppoll
|
2015-05-13 11:04:15 +00:00
|
|
|
fortify_fn(ppoll) int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
|
|
|
|
const sigset_t *mask)
|
2015-03-03 14:28:25 +00:00
|
|
|
{
|
|
|
|
__typeof__(sizeof 0) bos = __builtin_object_size(fds, 0);
|
|
|
|
|
|
|
|
if (nfds > bos / sizeof(struct pollfd))
|
|
|
|
__builtin_trap();
|
2015-05-13 11:04:15 +00:00
|
|
|
return __orig_ppoll(fds, nfds, timeout, mask);
|
2015-03-03 14:28:25 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-03-13 23:09:15 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2015-03-11 09:26:11 +00:00
|
|
|
#endif
|
|
|
|
|
2015-02-28 12:10:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|