summaryrefslogtreecommitdiff
path: root/include/sys
diff options
context:
space:
mode:
authorsin2015-05-13 12:04:15 +0100
committersin2015-05-13 12:05:29 +0100
commit158782b3bb791eae3c97947944c7023452bfbc96 (patch)
treeb76e70744ab0a2f76d781a65a0456b1b010c54df /include/sys
parent316a48653315b4bc36d8c50b542471b18441c9d5 (diff)
Add fortify_fn() helper in fortify-headers.h
Diffstat (limited to 'include/sys')
-rw-r--r--include/sys/socket.h29
1 files changed, 11 insertions, 18 deletions
diff --git a/include/sys/socket.h b/include/sys/socket.h
index d7871ae..5db1cb1 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -4,6 +4,7 @@
4#include_next <sys/socket.h> 4#include_next <sys/socket.h>
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#include "../fortify-headers.h"
7 8
8#ifdef __cplusplus 9#ifdef __cplusplus
9extern "C" { 10extern "C" {
@@ -14,50 +15,42 @@ extern "C" {
14#undef send 15#undef send
15#undef sendto 16#undef sendto
16 17
17__typeof__(recv) __recv_orig __asm__(__USER_LABEL_PREFIX__ "recv"); 18fortify_fn(recv) ssize_t recv(int sockfd, void *buf, size_t n, int flags)
18extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
19ssize_t recv(int sockfd, void *buf, size_t n, int flags)
20{ 19{
21 size_t bos = __builtin_object_size(buf, 0); 20 size_t bos = __builtin_object_size(buf, 0);
22 21
23 if (n > bos) 22 if (n > bos)
24 __builtin_trap(); 23 __builtin_trap();
25 return __recv_orig(sockfd, buf, n, flags); 24 return __orig_recv(sockfd, buf, n, flags);
26} 25}
27 26
28__typeof__(recvfrom) __recvfrom_orig __asm__(__USER_LABEL_PREFIX__ "recvfrom"); 27fortify_fn(recvfrom) ssize_t recvfrom(int sockfd, void *buf, size_t n, int flags,
29extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__)) 28 struct sockaddr *sa, socklen_t *salen)
30ssize_t recvfrom(int sockfd, void *buf, size_t n, int flags,
31 struct sockaddr *sa, socklen_t *salen)
32{ 29{
33 size_t bos = __builtin_object_size(buf, 0); 30 size_t bos = __builtin_object_size(buf, 0);
34 31
35 if (n > bos) 32 if (n > bos)
36 __builtin_trap(); 33 __builtin_trap();
37 return __recvfrom_orig(sockfd, buf, n, flags, sa, salen); 34 return __orig_recvfrom(sockfd, buf, n, flags, sa, salen);
38} 35}
39 36
40__typeof__(send) __send_orig __asm__(__USER_LABEL_PREFIX__ "send"); 37fortify_fn(send) ssize_t send(int sockfd, const void *buf, size_t n, int flags)
41extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
42ssize_t send(int sockfd, const void *buf, size_t n, int flags)
43{ 38{
44 size_t bos = __builtin_object_size(buf, 0); 39 size_t bos = __builtin_object_size(buf, 0);
45 40
46 if (n > bos) 41 if (n > bos)
47 __builtin_trap(); 42 __builtin_trap();
48 return __send_orig(sockfd, buf, n, flags); 43 return __orig_send(sockfd, buf, n, flags);
49} 44}
50 45
51__typeof__(sendto) __sendto_orig __asm__(__USER_LABEL_PREFIX__ "sendto"); 46fortify_fn(sendto) ssize_t sendto(int sockfd, const void *buf, size_t n, int flags,
52extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__)) 47 const struct sockaddr *sa, socklen_t salen)
53ssize_t sendto(int sockfd, const void *buf, size_t n, int flags,
54 const struct sockaddr *sa, socklen_t salen)
55{ 48{
56 size_t bos = __builtin_object_size(buf, 0); 49 size_t bos = __builtin_object_size(buf, 0);
57 50
58 if (n > bos) 51 if (n > bos)
59 __builtin_trap(); 52 __builtin_trap();
60 return __sendto_orig(sockfd, buf, n, flags, sa, salen); 53 return __orig_sendto(sockfd, buf, n, flags, sa, salen);
61} 54}
62 55
63#ifdef __cplusplus 56#ifdef __cplusplus