Add send() check
This commit is contained in:
parent
eb7c60712c
commit
d8afaf63d2
@ -27,10 +27,23 @@ __fortify_recvfrom(int sockfd, void *buf, size_t n, int flags, struct sockaddr *
|
|||||||
return recvfrom(sockfd, buf, n, flags, sa, salen);
|
return recvfrom(sockfd, buf, n, flags, sa, salen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline __attribute__ ((always_inline))
|
||||||
|
ssize_t
|
||||||
|
__fortify_send(int sockfd, const void *buf, size_t n, int flags)
|
||||||
|
{
|
||||||
|
size_t bos = __builtin_object_size(buf, 0);
|
||||||
|
|
||||||
|
if (n > bos)
|
||||||
|
__builtin_trap();
|
||||||
|
return send(sockfd, buf, n, flags);
|
||||||
|
}
|
||||||
|
|
||||||
#undef recv
|
#undef recv
|
||||||
#define recv(sockfd, buf, n, flags) __fortify_recv(sockfd, buf, n, flags)
|
#define recv(sockfd, buf, n, flags) __fortify_recv(sockfd, buf, n, flags)
|
||||||
#undef recvfrom
|
#undef recvfrom
|
||||||
#define recvfrom(sockfd, buf, n, flags, sa, salen) __fortify_recvfrom(sockfd, buf, n, flags, sa, salen)
|
#define recvfrom(sockfd, buf, n, flags, sa, salen) __fortify_recvfrom(sockfd, buf, n, flags, sa, salen)
|
||||||
|
#undef send
|
||||||
|
#define send(sockfd, buf, n, flags) __fortify_send(sockfd, buf, n, flags)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user