From eecef18261cc278fbc13ecbfb4e5bc10762cc794 Mon Sep 17 00:00:00 2001 From: sin Date: Tue, 24 Feb 2015 18:12:27 +0000 Subject: Remove compile time checks These can produce false positives. Given that we support fortify source level 1 we shouldn't break valid code. --- include/sys/socket.h | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'include/sys') diff --git a/include/sys/socket.h b/include/sys/socket.h index e8f8db6..85ba63b 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -5,33 +5,23 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#define __errordecl(name, msg) extern void name(void) __attribute__ ((__error__(msg))) - -__errordecl(__recv_error, "recv: buffer overflow detected"); static inline __attribute__ ((always_inline)) ssize_t __fortify_recv(int sockfd, void *buf, size_t n, int flags) { size_t bos = __builtin_object_size(buf, 0); - if (__builtin_constant_p(n) && n > bos) - __recv_error(); - if (n > bos) __builtin_trap(); return recv(sockfd, buf, n, flags); } -__errordecl(__recvfrom_error, "recvfrom: buffer overflow detected"); static inline __attribute__ ((always_inline)) ssize_t __fortify_recvfrom(int sockfd, void *buf, size_t n, int flags, struct sockaddr *sa, socklen_t *salen) { size_t bos = __builtin_object_size(buf, 0); - if (__builtin_constant_p(n) && n > bos) - __recvfrom_error(); - if (n > bos) __builtin_trap(); return recvfrom(sockfd, buf, n, flags, sa, salen); @@ -42,8 +32,6 @@ __fortify_recvfrom(int sockfd, void *buf, size_t n, int flags, struct sockaddr * #undef recvfrom #define recvfrom(sockfd, buf, n, flags, sa, salen) __fortify_recvfrom(sockfd, buf, n, flags, sa, salen) -#undef __errordecl - #endif #endif -- cgit v1.3