fortify-headers/include/sys/select.h

46 lines
884 B
C
Raw Normal View History

2015-01-30 16:17:01 +00:00
#ifndef FORTIFY_SYS_SELECT_H_
#define FORTIFY_SYS_SELECT_H_
#include_next <sys/select.h>
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
2015-03-11 09:26:11 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2015-01-30 16:17:01 +00:00
static inline __attribute__ ((always_inline))
int
__fortify_FD_CLR(int fd, fd_set *set)
{
2015-01-30 16:40:01 +00:00
size_t bos = __builtin_object_size(set, 0);
2015-01-30 16:17:01 +00:00
2015-01-30 16:40:01 +00:00
if (fd < 0 || fd >= FD_SETSIZE || bos < sizeof(fd_set))
2015-01-30 16:17:01 +00:00
__builtin_trap();
return FD_CLR(fd, set);
}
static inline __attribute__ ((always_inline))
int
__fortify_FD_SET(int fd, fd_set *set)
{
2015-01-30 16:40:01 +00:00
size_t bos = __builtin_object_size(set, 0);
2015-01-30 16:17:01 +00:00
2015-01-30 16:40:01 +00:00
if (fd < 0 || fd >= FD_SETSIZE || bos < sizeof(fd_set))
2015-01-30 16:17:01 +00:00
__builtin_trap();
return FD_SET(fd, set);
}
#undef FD_CLR
#define FD_CLR(fd, set) __fortify_FD_CLR(fd, set)
#undef FD_SET
#define FD_SET(fd, set) __fortify_FD_SET(fd, set)
2015-03-11 09:26:11 +00:00
#ifdef __cplusplus
}
#endif
2015-01-30 16:17:01 +00:00
#endif
#endif