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.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/include/sys/socket.h b/include/sys/socket.h
index 4dc228e..7044f65 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -18,7 +18,8 @@ __fortify_recv(int sockfd, void *buf, size_t n, int flags)
18 18
19static inline __attribute__ ((always_inline)) 19static inline __attribute__ ((always_inline))
20ssize_t 20ssize_t
21__fortify_recvfrom(int sockfd, void *buf, size_t n, int flags, struct sockaddr *sa, socklen_t *salen) 21__fortify_recvfrom(int sockfd, void *buf, size_t n, int flags,
22 struct sockaddr *sa, socklen_t *salen)
22{ 23{
23 size_t bos = __builtin_object_size(buf, 0); 24 size_t bos = __builtin_object_size(buf, 0);
24 25
@@ -38,12 +39,26 @@ __fortify_send(int sockfd, const void *buf, size_t n, int flags)
38 return send(sockfd, buf, n, flags); 39 return send(sockfd, buf, n, flags);
39} 40}
40 41
42static inline __attribute__ ((always_inline))
43ssize_t
44__fortify_sendto(int sockfd, const void *buf, size_t n, int flags,
45 const struct sockaddr *sa, socklen_t salen)
46{
47 size_t bos = __builtin_object_size(buf, 0);
48
49 if (n > bos)
50 __builtin_trap();
51 return sendto(sockfd, buf, n, flags, sa, salen);
52}
53
41#undef recv 54#undef recv
42#define recv(sockfd, buf, n, flags) __fortify_recv(sockfd, buf, n, flags) 55#define recv(sockfd, buf, n, flags) __fortify_recv(sockfd, buf, n, flags)
43#undef recvfrom 56#undef recvfrom
44#define recvfrom(sockfd, buf, n, flags, sa, salen) __fortify_recvfrom(sockfd, buf, n, flags, sa, salen) 57#define recvfrom(sockfd, buf, n, flags, sa, salen) __fortify_recvfrom(sockfd, buf, n, flags, sa, salen)
45#undef send 58#undef send
46#define send(sockfd, buf, n, flags) __fortify_send(sockfd, buf, n, flags) 59#define send(sockfd, buf, n, flags) __fortify_send(sockfd, buf, n, flags)
60#undef sendto
61#define sendto(sockfd, buf, n, flags, sa, salen) __fortify_sendto(sockfd, buf, n, flags, sa, salen)
47 62
48#endif 63#endif
49 64