diff options
Diffstat (limited to 'include/sys')
| -rw-r--r-- | include/sys/select.h | 10 | ||||
| -rw-r--r-- | include/sys/socket.h | 53 |
2 files changed, 30 insertions, 33 deletions
diff --git a/include/sys/select.h b/include/sys/select.h index c73613d..7838041 100644 --- a/include/sys/select.h +++ b/include/sys/select.h | |||
| @@ -7,9 +7,8 @@ | |||
| 7 | 7 | ||
| 8 | #ifndef __cplusplus | 8 | #ifndef __cplusplus |
| 9 | 9 | ||
| 10 | static inline __attribute__ ((always_inline)) | 10 | static __inline __attribute__((__always_inline__,__gnu_inline__)) |
| 11 | int | 11 | int __fortify_FD_CLR(int fd, fd_set *set) |
| 12 | __fortify_FD_CLR(int fd, fd_set *set) | ||
| 13 | { | 12 | { |
| 14 | size_t bos = __builtin_object_size(set, 0); | 13 | size_t bos = __builtin_object_size(set, 0); |
| 15 | 14 | ||
| @@ -18,9 +17,8 @@ __fortify_FD_CLR(int fd, fd_set *set) | |||
| 18 | return FD_CLR(fd, set); | 17 | return FD_CLR(fd, set); |
| 19 | } | 18 | } |
| 20 | 19 | ||
| 21 | static inline __attribute__ ((always_inline)) | 20 | static __inline __attribute__((__always_inline__,__gnu_inline__)) |
| 22 | int | 21 | int __fortify_FD_SET(int fd, fd_set *set) |
| 23 | __fortify_FD_SET(int fd, fd_set *set) | ||
| 24 | { | 22 | { |
| 25 | size_t bos = __builtin_object_size(set, 0); | 23 | size_t bos = __builtin_object_size(set, 0); |
| 26 | 24 | ||
diff --git a/include/sys/socket.h b/include/sys/socket.h index 5e6d679..4602866 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h | |||
| @@ -6,62 +6,61 @@ | |||
| 6 | #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 | 6 | #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 |
| 7 | 7 | ||
| 8 | #ifndef __cplusplus | 8 | #ifndef __cplusplus |
| 9 | #undef recv | ||
| 10 | #undef recvfrom | ||
| 11 | #undef send | ||
| 12 | #undef sendto | ||
| 9 | 13 | ||
| 10 | static inline __attribute__ ((always_inline)) | 14 | extern ssize_t __recv_orig(int, void *, size_t, int) |
| 11 | ssize_t | 15 | __asm__(__USER_LABEL_PREFIX__ "recv"); |
| 12 | __fortify_recv(int sockfd, void *buf, size_t n, int flags) | 16 | extern __inline __attribute__((__always_inline__,__gnu_inline__)) |
| 17 | ssize_t recv(int sockfd, void *buf, size_t n, int flags) | ||
| 13 | { | 18 | { |
| 14 | size_t bos = __builtin_object_size(buf, 0); | 19 | size_t bos = __builtin_object_size(buf, 0); |
| 15 | 20 | ||
| 16 | if (n > bos) | 21 | if (n > bos) |
| 17 | __builtin_trap(); | 22 | __builtin_trap(); |
| 18 | return recv(sockfd, buf, n, flags); | 23 | return __recv_orig(sockfd, buf, n, flags); |
| 19 | } | 24 | } |
| 20 | 25 | ||
| 21 | static inline __attribute__ ((always_inline)) | 26 | extern ssize_t __recvfrom_orig(int, void *, size_t, int, struct sockaddr *, socklen_t *) |
| 22 | ssize_t | 27 | __asm__(__USER_LABEL_PREFIX__ "recvfrom"); |
| 23 | __fortify_recvfrom(int sockfd, void *buf, size_t n, int flags, | 28 | extern __inline __attribute__((__always_inline__,__gnu_inline__)) |
| 24 | struct sockaddr *sa, socklen_t *salen) | 29 | ssize_t recvfrom(int sockfd, void *buf, size_t n, int flags, |
| 30 | struct sockaddr *sa, socklen_t *salen) | ||
| 25 | { | 31 | { |
| 26 | size_t bos = __builtin_object_size(buf, 0); | 32 | size_t bos = __builtin_object_size(buf, 0); |
| 27 | 33 | ||
| 28 | if (n > bos) | 34 | if (n > bos) |
| 29 | __builtin_trap(); | 35 | __builtin_trap(); |
| 30 | return recvfrom(sockfd, buf, n, flags, sa, salen); | 36 | return __recvfrom_orig(sockfd, buf, n, flags, sa, salen); |
| 31 | } | 37 | } |
| 32 | 38 | ||
| 33 | static inline __attribute__ ((always_inline)) | 39 | extern ssize_t __send_orig(int, const void *, size_t, int) |
| 34 | ssize_t | 40 | __asm__(__USER_LABEL_PREFIX__ "send"); |
| 35 | __fortify_send(int sockfd, const void *buf, size_t n, int flags) | 41 | extern __inline __attribute__((__always_inline__,__gnu_inline__)) |
| 42 | ssize_t send(int sockfd, const void *buf, size_t n, int flags) | ||
| 36 | { | 43 | { |
| 37 | size_t bos = __builtin_object_size(buf, 0); | 44 | size_t bos = __builtin_object_size(buf, 0); |
| 38 | 45 | ||
| 39 | if (n > bos) | 46 | if (n > bos) |
| 40 | __builtin_trap(); | 47 | __builtin_trap(); |
| 41 | return send(sockfd, buf, n, flags); | 48 | return __send_orig(sockfd, buf, n, flags); |
| 42 | } | 49 | } |
| 43 | 50 | ||
| 44 | static inline __attribute__ ((always_inline)) | 51 | extern ssize_t __sendto_orig(int, const void *, size_t, int, const struct sockaddr *, socklen_t) |
| 45 | ssize_t | 52 | __asm__(__USER_LABEL_PREFIX__ "sendto"); |
| 46 | __fortify_sendto(int sockfd, const void *buf, size_t n, int flags, | 53 | extern __inline __attribute__((__always_inline__,__gnu_inline__)) |
| 47 | const struct sockaddr *sa, socklen_t salen) | 54 | ssize_t sendto(int sockfd, const void *buf, size_t n, int flags, |
| 55 | const struct sockaddr *sa, socklen_t salen) | ||
| 48 | { | 56 | { |
| 49 | size_t bos = __builtin_object_size(buf, 0); | 57 | size_t bos = __builtin_object_size(buf, 0); |
| 50 | 58 | ||
| 51 | if (n > bos) | 59 | if (n > bos) |
| 52 | __builtin_trap(); | 60 | __builtin_trap(); |
| 53 | return sendto(sockfd, buf, n, flags, sa, salen); | 61 | return __sendto_orig(sockfd, buf, n, flags, sa, salen); |
| 54 | } | 62 | } |
| 55 | 63 | ||
| 56 | #undef recv | ||
| 57 | #define recv(sockfd, buf, n, flags) __fortify_recv(sockfd, buf, n, flags) | ||
| 58 | #undef recvfrom | ||
| 59 | #define recvfrom(sockfd, buf, n, flags, sa, salen) __fortify_recvfrom(sockfd, buf, n, flags, sa, salen) | ||
| 60 | #undef send | ||
| 61 | #define send(sockfd, buf, n, flags) __fortify_send(sockfd, buf, n, flags) | ||
| 62 | #undef sendto | ||
| 63 | #define sendto(sockfd, buf, n, flags, sa, salen) __fortify_sendto(sockfd, buf, n, flags, sa, salen) | ||
| 64 | |||
| 65 | #endif | 64 | #endif |
| 66 | 65 | ||
| 67 | #endif | 66 | #endif |
