diff options
| author | jvoisin | 2023-11-16 16:42:41 +0100 |
|---|---|---|
| committer | jvoisin | 2023-11-16 16:42:41 +0100 |
| commit | 52ec4848225a0e9f577272015ced52c45923d4ba (patch) | |
| tree | 2d0f2395dfd51d7b2810b7be3e549176b8a6c736 /include | |
| parent | cfdcaf72ca60db28ad8a7240a5a09e99151cab24 (diff) | |
Add hardening for select()
This is unlikely to be used, since fd_set is
usually manipulated by macros, but it doesn't hurt
to add a simple comparison.
Diffstat (limited to 'include')
| -rw-r--r-- | include/sys/select.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/sys/select.h b/include/sys/select.h index 29819be..f1cefee 100644 --- a/include/sys/select.h +++ b/include/sys/select.h | |||
| @@ -67,6 +67,18 @@ _STI int __fortify_FD_ISSET(int __f, fd_set * _FORTIFY_POS0 __s) | |||
| 67 | #undef FD_ISSET | 67 | #undef FD_ISSET |
| 68 | #define FD_ISSET(fd, set) __fortify_FD_ISSET(fd, set) | 68 | #define FD_ISSET(fd, set) __fortify_FD_ISSET(fd, set) |
| 69 | 69 | ||
| 70 | #ifndef __clang__ | ||
| 71 | #undef select | ||
| 72 | _FORTIFY_FN(select) int select(int nfds, fd_set* readfds, | ||
| 73 | fd_set* writefds, | ||
| 74 | fd_set* exceptfds, | ||
| 75 | struct timeval *timeout){ | ||
| 76 | if (nfds > FD_SETSIZE + 1) | ||
| 77 | __builtin_trap(); | ||
| 78 | return __orig_select(nfds, readfds, writefds, exceptfds, timeout); | ||
| 79 | } | ||
| 80 | #endif | ||
| 81 | |||
| 70 | #ifdef __cplusplus | 82 | #ifdef __cplusplus |
| 71 | } | 83 | } |
| 72 | #endif | 84 | #endif |
