diff options
| author | sin | 2015-02-24 18:12:27 +0000 |
|---|---|---|
| committer | sin | 2015-02-24 18:14:33 +0000 |
| commit | eecef18261cc278fbc13ecbfb4e5bc10762cc794 (patch) | |
| tree | 483074e25fbbcbb198ac4d339b84ace4205987f6 /include/sys | |
| parent | 9a77136c5914f6be50df195dac0f99424252a297 (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.h | 12 |
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"); | ||
| 11 | static inline __attribute__ ((always_inline)) | 8 | static inline __attribute__ ((always_inline)) |
| 12 | ssize_t | 9 | ssize_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"); | ||
| 26 | static inline __attribute__ ((always_inline)) | 19 | static inline __attribute__ ((always_inline)) |
| 27 | ssize_t | 20 | ssize_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 |
