diff options
Diffstat (limited to 'include/sys')
| -rw-r--r-- | include/sys/select.h | 13 | ||||
| -rw-r--r-- | include/sys/socket.h | 13 |
2 files changed, 20 insertions, 6 deletions
diff --git a/include/sys/select.h b/include/sys/select.h index 1a5afbe..265c7e1 100644 --- a/include/sys/select.h +++ b/include/sys/select.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> | 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> |
| 3 | * Copyright (C) 2022 q66 <q66@chimera-linux.org> | ||
| 3 | * | 4 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted. | 6 | * purpose with or without fee is hereby granted. |
| @@ -27,8 +28,14 @@ __extension__ | |||
| 27 | extern "C" { | 28 | extern "C" { |
| 28 | #endif | 29 | #endif |
| 29 | 30 | ||
| 31 | #ifdef __clang__ | ||
| 32 | #define _FORTIFY_FD_POS0 const __attribute__((__pass_object_size__(0))) | ||
| 33 | #else | ||
| 34 | #define _FORTIFY_FD_POS0 | ||
| 35 | #endif | ||
| 36 | |||
| 30 | static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) | 37 | static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) |
| 31 | void __fortify_FD_CLR(int __f, fd_set *__s) | 38 | void __fortify_FD_CLR(int __f, fd_set * _FORTIFY_FD_POS0 __s) |
| 32 | { | 39 | { |
| 33 | size_t __b = __bos(__s, 0); | 40 | size_t __b = __bos(__s, 0); |
| 34 | 41 | ||
| @@ -38,7 +45,7 @@ void __fortify_FD_CLR(int __f, fd_set *__s) | |||
| 38 | } | 45 | } |
| 39 | 46 | ||
| 40 | static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) | 47 | static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) |
| 41 | void __fortify_FD_SET(int __f, fd_set *__s) | 48 | void __fortify_FD_SET(int __f, fd_set * _FORTIFY_FD_POS0 __s) |
| 42 | { | 49 | { |
| 43 | size_t __b = __bos(__s, 0); | 50 | size_t __b = __bos(__s, 0); |
| 44 | 51 | ||
| @@ -47,6 +54,8 @@ void __fortify_FD_SET(int __f, fd_set *__s) | |||
| 47 | FD_SET(__f, __s); | 54 | FD_SET(__f, __s); |
| 48 | } | 55 | } |
| 49 | 56 | ||
| 57 | #undef _FORTIFY_FD_POS0 | ||
| 58 | |||
| 50 | #undef FD_CLR | 59 | #undef FD_CLR |
| 51 | #define FD_CLR(fd, set) __fortify_FD_CLR(fd, set) | 60 | #define FD_CLR(fd, set) __fortify_FD_CLR(fd, set) |
| 52 | #undef FD_SET | 61 | #undef FD_SET |
diff --git a/include/sys/socket.h b/include/sys/socket.h index 604d65a..7dfa71a 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> | 2 | * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> |
| 3 | * Copyright (C) 2022 q66 <q66@chimera-linux.org> | ||
| 3 | * | 4 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted. | 6 | * purpose with or without fee is hereby granted. |
| @@ -33,7 +34,8 @@ extern "C" { | |||
| 33 | #undef send | 34 | #undef send |
| 34 | #undef sendto | 35 | #undef sendto |
| 35 | 36 | ||
| 36 | _FORTIFY_FN(recv) ssize_t recv(int __f, void *__s, size_t __n, int __fl) | 37 | _FORTIFY_FN(recv) ssize_t recv(int __f, void * _FORTIFY_POS0 __s, size_t __n, |
| 38 | int __fl) | ||
| 37 | { | 39 | { |
| 38 | size_t __b = __bos(__s, 0); | 40 | size_t __b = __bos(__s, 0); |
| 39 | 41 | ||
| @@ -42,7 +44,8 @@ _FORTIFY_FN(recv) ssize_t recv(int __f, void *__s, size_t __n, int __fl) | |||
| 42 | return __orig_recv(__f, __s, __n, __fl); | 44 | return __orig_recv(__f, __s, __n, __fl); |
| 43 | } | 45 | } |
| 44 | 46 | ||
| 45 | _FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void *__s, size_t __n, int __fl, | 47 | _FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void * _FORTIFY_POS0 __s, |
| 48 | size_t __n, int __fl, | ||
| 46 | struct sockaddr *__a, socklen_t *__l) | 49 | struct sockaddr *__a, socklen_t *__l) |
| 47 | { | 50 | { |
| 48 | size_t __b = __bos(__s, 0); | 51 | size_t __b = __bos(__s, 0); |
| @@ -52,7 +55,8 @@ _FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void *__s, size_t __n, int __fl, | |||
| 52 | return __orig_recvfrom(__f, __s, __n, __fl, __a, __l); | 55 | return __orig_recvfrom(__f, __s, __n, __fl, __a, __l); |
| 53 | } | 56 | } |
| 54 | 57 | ||
| 55 | _FORTIFY_FN(send) ssize_t send(int __f, const void *__s, size_t __n, int __fl) | 58 | _FORTIFY_FN(send) ssize_t send(int __f, const void * _FORTIFY_POS0 __s, |
| 59 | size_t __n, int __fl) | ||
| 56 | { | 60 | { |
| 57 | size_t __b = __bos(__s, 0); | 61 | size_t __b = __bos(__s, 0); |
| 58 | 62 | ||
| @@ -61,7 +65,8 @@ _FORTIFY_FN(send) ssize_t send(int __f, const void *__s, size_t __n, int __fl) | |||
| 61 | return __orig_send(__f, __s, __n, __fl); | 65 | return __orig_send(__f, __s, __n, __fl); |
| 62 | } | 66 | } |
| 63 | 67 | ||
| 64 | _FORTIFY_FN(sendto) ssize_t sendto(int __f, const void *__s, size_t __n, int __fl, | 68 | _FORTIFY_FN(sendto) ssize_t sendto(int __f, const void * _FORTIFY_POS0 __s, |
| 69 | size_t __n, int __fl, | ||
| 65 | const struct sockaddr *__a, socklen_t __l) | 70 | const struct sockaddr *__a, socklen_t __l) |
| 66 | { | 71 | { |
| 67 | size_t __b = __bos(__s, 0); | 72 | size_t __b = __bos(__s, 0); |
