summaryrefslogtreecommitdiff
path: root/include/sys
diff options
context:
space:
mode:
authorsin2015-02-24 18:12:27 +0000
committersin2015-02-24 18:14:33 +0000
commiteecef18261cc278fbc13ecbfb4e5bc10762cc794 (patch)
tree483074e25fbbcbb198ac4d339b84ace4205987f6 /include/sys
parent9a77136c5914f6be50df195dac0f99424252a297 (diff)
Remove compile time checks
These can produce false positives. Given that we support fortify source level 1 we shouldn't break valid code.
Diffstat (limited to 'include/sys')
-rw-r--r--include/sys/socket.h12
1 files changed, 0 insertions, 12 deletions
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 @@
5 5
6#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 6#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
7 7
8#define __errordecl(name, msg) extern void name(void) __attribute__ ((__error__(msg)))
9
10__errordecl(__recv_error, "recv: buffer overflow detected");
11static inline __attribute__ ((always_inline)) 8static inline __attribute__ ((always_inline))
12ssize_t 9ssize_t
13__fortify_recv(int sockfd, void *buf, size_t n, int flags) 10__fortify_recv(int sockfd, void *buf, size_t n, int flags)
14{ 11{
15 size_t bos = __builtin_object_size(buf, 0); 12 size_t bos = __builtin_object_size(buf, 0);
16 13
17 if (__builtin_constant_p(n) && n > bos)
18 __recv_error();
19
20 if (n > bos) 14 if (n > bos)
21 __builtin_trap(); 15 __builtin_trap();
22 return recv(sockfd, buf, n, flags); 16 return recv(sockfd, buf, n, flags);
23} 17}
24 18
25__errordecl(__recvfrom_error, "recvfrom: buffer overflow detected");
26static inline __attribute__ ((always_inline)) 19static inline __attribute__ ((always_inline))
27ssize_t 20ssize_t
28__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, struct sockaddr *sa, socklen_t *salen)
29{ 22{
30 size_t bos = __builtin_object_size(buf, 0); 23 size_t bos = __builtin_object_size(buf, 0);
31 24
32 if (__builtin_constant_p(n) && n > bos)
33 __recvfrom_error();
34
35 if (n > bos) 25 if (n > bos)
36 __builtin_trap(); 26 __builtin_trap();
37 return recvfrom(sockfd, buf, n, flags, sa, salen); 27 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 *
42#undef recvfrom 32#undef recvfrom
43#define recvfrom(sockfd, buf, n, flags, sa, salen) __fortify_recvfrom(sockfd, buf, n, flags, sa, salen) 33#define recvfrom(sockfd, buf, n, flags, sa, salen) __fortify_recvfrom(sockfd, buf, n, flags, sa, salen)
44 34
45#undef __errordecl
46
47#endif 35#endif
48 36
49#endif 37#endif