diff options
Diffstat (limited to 'include/sys')
| -rw-r--r-- | include/sys/socket.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/sys/socket.h b/include/sys/socket.h index 85ba63b..4dc228e 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h | |||
| @@ -27,10 +27,23 @@ __fortify_recvfrom(int sockfd, void *buf, size_t n, int flags, struct sockaddr * | |||
| 27 | return recvfrom(sockfd, buf, n, flags, sa, salen); | 27 | return recvfrom(sockfd, buf, n, flags, sa, salen); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | static inline __attribute__ ((always_inline)) | ||
| 31 | ssize_t | ||
| 32 | __fortify_send(int sockfd, const void *buf, size_t n, int flags) | ||
| 33 | { | ||
| 34 | size_t bos = __builtin_object_size(buf, 0); | ||
| 35 | |||
| 36 | if (n > bos) | ||
| 37 | __builtin_trap(); | ||
| 38 | return send(sockfd, buf, n, flags); | ||
| 39 | } | ||
| 40 | |||
| 30 | #undef recv | 41 | #undef recv |
| 31 | #define recv(sockfd, buf, n, flags) __fortify_recv(sockfd, buf, n, flags) | 42 | #define recv(sockfd, buf, n, flags) __fortify_recv(sockfd, buf, n, flags) |
| 32 | #undef recvfrom | 43 | #undef recvfrom |
| 33 | #define recvfrom(sockfd, buf, n, flags, sa, salen) __fortify_recvfrom(sockfd, buf, n, flags, sa, salen) | 44 | #define recvfrom(sockfd, buf, n, flags, sa, salen) __fortify_recvfrom(sockfd, buf, n, flags, sa, salen) |
| 45 | #undef send | ||
| 46 | #define send(sockfd, buf, n, flags) __fortify_send(sockfd, buf, n, flags) | ||
| 34 | 47 | ||
| 35 | #endif | 48 | #endif |
| 36 | 49 | ||
