summaryrefslogtreecommitdiff
path: root/include/sys/socket.h
diff options
context:
space:
mode:
authorsin2015-02-24 19:37:25 +0000
committersin2015-02-24 19:37:25 +0000
commitd8afaf63d24933f6e1706c4019155b8e09fe9d32 (patch)
tree6c667301930fa057a23b9af7bde16b37a8f3f0c1 /include/sys/socket.h
parenteb7c60712c85bfea0f4265219d1f457d144984ff (diff)
Add send() check
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