summaryrefslogtreecommitdiff
path: root/include/sys/socket.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sys/socket.h')
-rw-r--r--include/sys/socket.h13
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
30static inline __attribute__ ((always_inline))
31ssize_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