summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/fortify-headers.h4
-rw-r--r--include/poll.h2
-rw-r--r--include/stdio.h11
-rw-r--r--include/stdlib.h5
-rw-r--r--include/string.h26
-rw-r--r--include/strings.h3
-rw-r--r--include/unistd.h13
-rw-r--r--include/wchar.h16
8 files changed, 30 insertions, 50 deletions
diff --git a/include/fortify-headers.h b/include/fortify-headers.h
index bc7bf00..46d5610 100644
--- a/include/fortify-headers.h
+++ b/include/fortify-headers.h
@@ -100,8 +100,8 @@
100#define __alloc_size(...) 100#define __alloc_size(...)
101#endif 101#endif
102 102
103#if __has_attribute (__diagnose_as_builtin) 103#if __has_attribute (diagnose_as_builtin)
104#define __diagnose_as_builtin(...) __attribute__ ((__diagnose_as_builtin (__VA_ARGS__))) 104#define __diagnose_as_builtin(...) __attribute__ ((diagnose_as_builtin (__VA_ARGS__)))
105#else 105#else
106#define __diagnose_as_builtin(...) 106#define __diagnose_as_builtin(...)
107#endif 107#endif
diff --git a/include/poll.h b/include/poll.h
index 10df4b3..8e8de6c 100644
--- a/include/poll.h
+++ b/include/poll.h
@@ -31,7 +31,6 @@ extern "C" {
31 31
32#undef poll 32#undef poll
33 33
34__diagnose_as_builtin(__builtin_pollfd, 1, 2, 3)
35_FORTIFY_FN(poll) int poll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n, int __s) 34_FORTIFY_FN(poll) int poll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n, int __s)
36{ 35{
37 size_t __b = __bos(__f, 0); 36 size_t __b = __bos(__f, 0);
@@ -43,7 +42,6 @@ _FORTIFY_FN(poll) int poll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n, int __
43 42
44#if defined(_GNU_SOURCE) && !_REDIR_TIME64 43#if defined(_GNU_SOURCE) && !_REDIR_TIME64
45#undef ppoll 44#undef ppoll
46__diagnose_as_builtin(__builtin_ppollfd, 1, 2, 3, 4)
47_FORTIFY_FN(ppoll) int ppoll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n, 45_FORTIFY_FN(ppoll) int ppoll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n,
48 const struct timespec *__s, const sigset_t *__m) 46 const struct timespec *__s, const sigset_t *__m)
49{ 47{
diff --git a/include/stdio.h b/include/stdio.h
index 9d29e94..000a72d 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -40,14 +40,12 @@ extern "C" {
40#undef vsprintf 40#undef vsprintf
41 41
42__access(read_only, 2) 42__access(read_only, 2)
43__diagnose_as_builtin(__builtin_fdopen, 1, 2)
44_FORTIFY_FN(fdopen) FILE *fdopen(int __f, const char* _FORTIFY_POS0 __m) 43_FORTIFY_FN(fdopen) FILE *fdopen(int __f, const char* _FORTIFY_POS0 __m)
45{ 44{
46 return __orig_fdopen(__f, __m); 45 return __orig_fdopen(__f, __m);
47} 46}
48 47
49__access(write_only, 1, 2) 48__access(write_only, 1, 2)
50__diagnose_as_builtin(__builtin_fgets, 1, 2, 3)
51_FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f) 49_FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f)
52{ 50{
53 size_t __b = __bos(__s, 0); 51 size_t __b = __bos(__s, 0);
@@ -58,7 +56,6 @@ _FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f)
58} 56}
59 57
60__malloc(malloc (fclose, 1)) 58__malloc(malloc (fclose, 1))
61__diagnose_as_builtin(__builtin_fmemopen, 1, 2, 3)
62_FORTIFY_FN(fmemopen) FILE *fmemopen(void* _FORTIFY_POS0 __b, size_t __s, const char* _FORTIFY_POS0 __m) 59_FORTIFY_FN(fmemopen) FILE *fmemopen(void* _FORTIFY_POS0 __b, size_t __s, const char* _FORTIFY_POS0 __m)
63{ 60{
64 return __orig_fmemopen(__b, __s, __m); 61 return __orig_fmemopen(__b, __s, __m);
@@ -67,14 +64,12 @@ _FORTIFY_FN(fmemopen) FILE *fmemopen(void* _FORTIFY_POS0 __b, size_t __s, const
67__access(read_only, 1) 64__access(read_only, 1)
68__access(read_only, 2) 65__access(read_only, 2)
69__malloc(malloc (fclose, 1)) 66__malloc(malloc (fclose, 1))
70__diagnose_as_builtin(__builtin_fopen, 1, 2)
71_FORTIFY_FN(fopen) FILE *fopen(const char* _FORTIFY_POS0 __p, const char* _FORTIFY_POS0 __m) 67_FORTIFY_FN(fopen) FILE *fopen(const char* _FORTIFY_POS0 __p, const char* _FORTIFY_POS0 __m)
72{ 68{
73 return __orig_fopen(__p, __m); 69 return __orig_fopen(__p, __m);
74} 70}
75 71
76__access(write_only, 1) 72__access(write_only, 1)
77__diagnose_as_builtin(__builtin_fread, 1, 2, 3, 4)
78_FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n, 73_FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n,
79 size_t __m, FILE *__f) 74 size_t __m, FILE *__f)
80{ 75{
@@ -88,7 +83,6 @@ _FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n,
88} 83}
89 84
90__access(read_only, 1) 85__access(read_only, 1)
91__diagnose_as_builtin(__builtin_fwrite, 1, 2, 3, 4)
92_FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n, 86_FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n,
93 size_t __m, FILE *__f) 87 size_t __m, FILE *__f)
94{ 88{
@@ -104,7 +98,6 @@ _FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n,
104__access(read_only, 1) 98__access(read_only, 1)
105__access(read_only, 2) 99__access(read_only, 2)
106__malloc(malloc (pclose, 1)) 100__malloc(malloc (pclose, 1))
107__diagnose_as_builtin(__builtin_fwrite, 1, 2)
108_FORTIFY_FN(popen) FILE *popen(const char* _FORTIFY_POS0 __c, const char* _FORTIFY_POS0 __t) 101_FORTIFY_FN(popen) FILE *popen(const char* _FORTIFY_POS0 __c, const char* _FORTIFY_POS0 __t)
109{ 102{
110 return __orig_popen(__c, __t); 103 return __orig_popen(__c, __t);
@@ -122,7 +115,9 @@ _FORTIFY_FN(tmpfile) FILE *tmpfile(void)
122__access(read_write, 1, 2) 115__access(read_write, 1, 2)
123__access(read_only, 3) 116__access(read_only, 3)
124__format(printf, 3, 0) 117__format(printf, 3, 0)
118#if __has_builtin(__builtin_vsnprintf)
125__diagnose_as_builtin(__builtin_vsnprintf, 1, 2, 3, 4) 119__diagnose_as_builtin(__builtin_vsnprintf, 1, 2, 3, 4)
120#endif
126_FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n, 121_FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n,
127 const char *__f, __builtin_va_list __v) 122 const char *__f, __builtin_va_list __v)
128{ 123{
@@ -136,7 +131,9 @@ _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n,
136__format(printf, 2, 0) 131__format(printf, 2, 0)
137__access(read_write, 1) 132__access(read_write, 1)
138__access(read_only, 2) 133__access(read_only, 2)
134#if __has_builtin(__builtin_vsprintf)
139__diagnose_as_builtin(__builtin_vsprintf, 1, 2, 3) 135__diagnose_as_builtin(__builtin_vsprintf, 1, 2, 3)
136#endif
140_FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f, 137_FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f,
141 __builtin_va_list __v) 138 __builtin_va_list __v)
142{ 139{
diff --git a/include/stdlib.h b/include/stdlib.h
index 1a92bff..734f0e6 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -43,7 +43,6 @@ extern "C" {
43__malloc(malloc (free, 1)) 43__malloc(malloc (free, 1))
44__alloc_size(1) 44__alloc_size(1)
45__warn_unused_result 45__warn_unused_result
46__diagnose_as_builtin(__builtin_malloc, 1)
47_FORTIFY_FN(malloc) void *malloc(size_t __s) 46_FORTIFY_FN(malloc) void *malloc(size_t __s)
48{ 47{
49 return __orig_malloc(__s); 48 return __orig_malloc(__s);
@@ -51,7 +50,6 @@ _FORTIFY_FN(malloc) void *malloc(size_t __s)
51 50
52__alloc_size(2) 51__alloc_size(2)
53__warn_unused_result 52__warn_unused_result
54__diagnose_as_builtin(__builtin_realloc, 1, 2)
55_FORTIFY_FN(realloc) void *realloc(void *__p, size_t __s) 53_FORTIFY_FN(realloc) void *realloc(void *__p, size_t __s)
56{ 54{
57 return __orig_realloc(__p, __s); 55 return __orig_realloc(__p, __s);
@@ -59,7 +57,6 @@ _FORTIFY_FN(realloc) void *realloc(void *__p, size_t __s)
59 57
60__alloc_size(1, 2) 58__alloc_size(1, 2)
61__warn_unused_result 59__warn_unused_result
62__diagnose_as_builtin(__builtin_calloc, 1, 2)
63_FORTIFY_FN(calloc) void *calloc(size_t __n, size_t __s) 60_FORTIFY_FN(calloc) void *calloc(size_t __n, size_t __s)
64{ 61{
65 return __orig_calloc(__n, __s); 62 return __orig_calloc(__n, __s);
@@ -69,7 +66,6 @@ _FORTIFY_FN(calloc) void *calloc(size_t __n, size_t __s)
69#undef reallocarray 66#undef reallocarray
70__alloc_size (2, 3) 67__alloc_size (2, 3)
71__warn_unused_result 68__warn_unused_result
72__diagnose_as_builtin(__builtin_reallocarray, 1, 2, 3)
73_FORTIFY_FN(reallocarray) void* reallocarray(void* __p, size_t __n, size_t __s) 69_FORTIFY_FN(reallocarray) void* reallocarray(void* __p, size_t __n, size_t __s)
74{ 70{
75 return __orig_reallocarray(__p, __n, __s); 71 return __orig_reallocarray(__p, __n, __s);
@@ -79,7 +75,6 @@ _FORTIFY_FN(reallocarray) void* reallocarray(void* __p, size_t __n, size_t __s)
79/* FIXME clang */ 75/* FIXME clang */
80#if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__) 76#if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__)
81#undef realpath 77#undef realpath
82__diagnose_as_builtin(__builtin_realpath, 1, 2)
83__warning_if(__p == NULL, "'realpath' called with path set to `NULL`; did you invert the arguments?") 78__warning_if(__p == NULL, "'realpath' called with path set to `NULL`; did you invert the arguments?")
84_FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) 79_FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r)
85{ 80{
diff --git a/include/string.h b/include/string.h
index 010b7f2..2735b55 100644
--- a/include/string.h
+++ b/include/string.h
@@ -40,7 +40,9 @@ extern "C" {
40 40
41__access(write_only, 1, 3) 41__access(write_only, 1, 3)
42__access(read_only, 2, 3) 42__access(read_only, 2, 3)
43#if __has_builtin(__builtin_mempcpy)
43__diagnose_as_builtin(__builtin_memcpy, 1, 2, 3) 44__diagnose_as_builtin(__builtin_memcpy, 1, 2, 3)
45#endif
44_FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od, 46_FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od,
45 const void * _FORTIFY_POS0 __os, size_t __n) 47 const void * _FORTIFY_POS0 __os, size_t __n)
46__error_if((__bos(__od, 0) < __n), "'memcpy' called with `n` bigger than the size of `d`.") 48__error_if((__bos(__od, 0) < __n), "'memcpy' called with `n` bigger than the size of `d`.")
@@ -59,7 +61,9 @@ __error_if((__bos(__od, 0) < __n), "'memcpy' called with `n` bigger than the siz
59 61
60__access(write_only, 1, 3) 62__access(write_only, 1, 3)
61__access(read_only, 2, 3) 63__access(read_only, 2, 3)
64#if __has_builtin(__builtin_memmove)
62__diagnose_as_builtin(__builtin_memmove, 1, 2, 3) 65__diagnose_as_builtin(__builtin_memmove, 1, 2, 3)
66#endif
63_FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d, 67_FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d,
64 const void * _FORTIFY_POS0 __s, size_t __n) 68 const void * _FORTIFY_POS0 __s, size_t __n)
65{ 69{
@@ -72,7 +76,9 @@ _FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d,
72} 76}
73 77
74__access(write_only, 1, 3) 78__access(write_only, 1, 3)
79#if __has_builtin(__builtin_memset)
75__diagnose_as_builtin(__builtin_memset, 1, 2, 3) 80__diagnose_as_builtin(__builtin_memset, 1, 2, 3)
81#endif
76_FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n) 82_FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n)
77__warning_if(__c != 0 && __n == 0, "'memset' will set `0` bytes; did you invert the arguments?") 83__warning_if(__c != 0 && __n == 0, "'memset' will set `0` bytes; did you invert the arguments?")
78{ 84{
@@ -84,7 +90,9 @@ __warning_if(__c != 0 && __n == 0, "'memset' will set `0` bytes; did you invert
84} 90}
85 91
86__access(read_only, 1, 3) 92__access(read_only, 1, 3)
93#if __has_builtin(__builtin_memchr)
87__diagnose_as_builtin(__builtin_memchr, 1, 2, 3) 94__diagnose_as_builtin(__builtin_memchr, 1, 2, 3)
95#endif
88_FORTIFY_FN(memchr) void *memchr(const void * _FORTIFY_POS0 __d, int __c, size_t __n) 96_FORTIFY_FN(memchr) void *memchr(const void * _FORTIFY_POS0 __d, int __c, size_t __n)
89{ 97{
90 size_t __b = __bos(__d, 0); 98 size_t __b = __bos(__d, 0);
@@ -95,7 +103,6 @@ _FORTIFY_FN(memchr) void *memchr(const void * _FORTIFY_POS0 __d, int __c, size_t
95} 103}
96 104
97__access(read_only, 1, 2) 105__access(read_only, 1, 2)
98__diagnose_as_builtin(__builtin_strchr, 1, 2, 3)
99_FORTIFY_FN(strchr) char *strchr(const char * _FORTIFY_POS0 __s, int __c) 106_FORTIFY_FN(strchr) char *strchr(const char * _FORTIFY_POS0 __s, int __c)
100{ 107{
101 size_t __b = __bos(__s, 0); 108 size_t __b = __bos(__s, 0);
@@ -107,7 +114,6 @@ _FORTIFY_FN(strchr) char *strchr(const char * _FORTIFY_POS0 __s, int __c)
107} 114}
108 115
109__access(read_only, 1, 2) 116__access(read_only, 1, 2)
110__diagnose_as_builtin(__builtin_strrchr, 1, 2, 3)
111_FORTIFY_FN(strrchr) char *strrchr(const char * _FORTIFY_POS0 __s, int __c) 117_FORTIFY_FN(strrchr) char *strrchr(const char * _FORTIFY_POS0 __s, int __c)
112{ 118{
113 size_t __b = __bos(__s, 0); 119 size_t __b = __bos(__s, 0);
@@ -124,7 +130,9 @@ _FORTIFY_FN(strrchr) char *strrchr(const char * _FORTIFY_POS0 __s, int __c)
124#undef stpcpy 130#undef stpcpy
125__access(write_only, 1) 131__access(write_only, 1)
126__access(read_only, 2) 132__access(read_only, 2)
133#if __has_builtin(__builtin_stpcpy)
127__diagnose_as_builtin(__builtin_stpcpy, 1, 2) 134__diagnose_as_builtin(__builtin_stpcpy, 1, 2)
135#endif
128_FORTIFY_FN(stpcpy) char *stpcpy(char * _FORTIFY_POS0 __d, const char *__s) 136_FORTIFY_FN(stpcpy) char *stpcpy(char * _FORTIFY_POS0 __d, const char *__s)
129{ 137{
130 size_t __n = strlen(__s) + 1; 138 size_t __n = strlen(__s) + 1;
@@ -141,7 +149,9 @@ _FORTIFY_FN(stpcpy) char *stpcpy(char * _FORTIFY_POS0 __d, const char *__s)
141#undef stpncpy 149#undef stpncpy
142__access(write_only, 1) 150__access(write_only, 1)
143__access(read_only, 2, 3) 151__access(read_only, 2, 3)
152#if __has_builtin(__builtin_stpncpy)
144__diagnose_as_builtin(__builtin_stpncpy, 1, 2, 3) 153__diagnose_as_builtin(__builtin_stpncpy, 1, 2, 3)
154#endif
145_FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s, 155_FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s,
146 size_t __n) 156 size_t __n)
147{ 157{
@@ -157,7 +167,9 @@ _FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s,
157 167
158__access (read_write, 1) 168__access (read_write, 1)
159__access (read_only, 2) 169__access (read_only, 2)
170#if __has_builtin(__builtin_strcat)
160__diagnose_as_builtin(__builtin_strcat, 1, 2) 171__diagnose_as_builtin(__builtin_strcat, 1, 2)
172#endif
161_FORTIFY_FN(strcat) char *strcat(char * _FORTIFY_POS0 __d, const char *__s) 173_FORTIFY_FN(strcat) char *strcat(char * _FORTIFY_POS0 __d, const char *__s)
162{ 174{
163 size_t __b = __bos(__d, 0); 175 size_t __b = __bos(__d, 0);
@@ -169,7 +181,9 @@ _FORTIFY_FN(strcat) char *strcat(char * _FORTIFY_POS0 __d, const char *__s)
169 181
170__access (write_only, 1) 182__access (write_only, 1)
171__access (read_only, 2) 183__access (read_only, 2)
184#if __has_builtin(__builtin_strcpy)
172__diagnose_as_builtin(__builtin_strcpy, 1, 2) 185__diagnose_as_builtin(__builtin_strcpy, 1, 2)
186#endif
173_FORTIFY_FN(strcpy) char *strcpy(char * _FORTIFY_POS0 __d, const char *__s) 187_FORTIFY_FN(strcpy) char *strcpy(char * _FORTIFY_POS0 __d, const char *__s)
174{ 188{
175 size_t __n = strlen(__s) + 1; 189 size_t __n = strlen(__s) + 1;
@@ -185,7 +199,9 @@ _FORTIFY_FN(strcpy) char *strcpy(char * _FORTIFY_POS0 __d, const char *__s)
185 199
186__access (read_write, 1) 200__access (read_write, 1)
187__access (read_only, 2, 3) 201__access (read_only, 2, 3)
202#if __has_builtin(__builtin_strncat)
188__diagnose_as_builtin(__builtin_strncat, 1, 2, 3) 203__diagnose_as_builtin(__builtin_strncat, 1, 2, 3)
204#endif
189_FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s, 205_FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s,
190 size_t __n) 206 size_t __n)
191{ 207{
@@ -202,7 +218,9 @@ _FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s,
202 218
203__access (write_only, 1) 219__access (write_only, 1)
204__access (read_only, 2, 3) 220__access (read_only, 2, 3)
221#if __has_builtin(__builtin_strncpy)
205__diagnose_as_builtin(__builtin_strncpy, 1, 2, 3) 222__diagnose_as_builtin(__builtin_strncpy, 1, 2, 3)
223#endif
206_FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d, 224_FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d,
207 const char *__s, size_t __n) 225 const char *__s, size_t __n)
208{ 226{
@@ -219,7 +237,9 @@ _FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d,
219#undef mempcpy 237#undef mempcpy
220__access(write_only, 1) 238__access(write_only, 1)
221__access(read_only, 2, 3) 239__access(read_only, 2, 3)
240#if __has_builtin(__builtin_mempcpy)
222__diagnose_as_builtin(__builtin_mempcpy, 1, 2, 3) 241__diagnose_as_builtin(__builtin_mempcpy, 1, 2, 3)
242#endif
223_FORTIFY_FN(mempcpy) void *mempcpy(void * _FORTIFY_POS0 __d, 243_FORTIFY_FN(mempcpy) void *mempcpy(void * _FORTIFY_POS0 __d,
224 const void * _FORTIFY_POS0 __s, size_t __n) 244 const void * _FORTIFY_POS0 __s, size_t __n)
225{ 245{
@@ -237,7 +257,6 @@ _FORTIFY_FN(mempcpy) void *mempcpy(void * _FORTIFY_POS0 __d,
237#undef strlcpy 257#undef strlcpy
238__access (read_write, 1) 258__access (read_write, 1)
239__access (read_only, 2, 3) 259__access (read_only, 2, 3)
240__diagnose_as_builtin(__builtin_strlcat, 1, 2, 3)
241_FORTIFY_FN(strlcat) size_t strlcat(char * _FORTIFY_POS0 __d, 260_FORTIFY_FN(strlcat) size_t strlcat(char * _FORTIFY_POS0 __d,
242 const char *__s, size_t __n) 261 const char *__s, size_t __n)
243{ 262{
@@ -250,7 +269,6 @@ _FORTIFY_FN(strlcat) size_t strlcat(char * _FORTIFY_POS0 __d,
250 269
251__access (write_only, 1) 270__access (write_only, 1)
252__access (read_only, 2, 3) 271__access (read_only, 2, 3)
253__diagnose_as_builtin(__builtin_strlcpy, 1, 2, 3)
254_FORTIFY_FN(strlcpy) size_t strlcpy(char * _FORTIFY_POS0 __d, 272_FORTIFY_FN(strlcpy) size_t strlcpy(char * _FORTIFY_POS0 __d,
255 const char *__s, size_t __n) 273 const char *__s, size_t __n)
256{ 274{
diff --git a/include/strings.h b/include/strings.h
index 530572a..8b99ccd 100644
--- a/include/strings.h
+++ b/include/strings.h
@@ -33,7 +33,6 @@ extern "C" {
33#undef bzero 33#undef bzero
34__access(write_only, 2, 3) 34__access(write_only, 2, 3)
35__access(read_only, 1, 3) 35__access(read_only, 1, 3)
36__diagnose_as_builtin(__builtin_bcopy, 1, 2, 3)
37_FORTIFY_FN(bcopy) void bcopy(const void * _FORTIFY_POS0 __s, 36_FORTIFY_FN(bcopy) void bcopy(const void * _FORTIFY_POS0 __s,
38 void * _FORTIFY_POS0 __d, size_t __n) 37 void * _FORTIFY_POS0 __d, size_t __n)
39{ 38{
@@ -46,7 +45,9 @@ _FORTIFY_FN(bcopy) void bcopy(const void * _FORTIFY_POS0 __s,
46} 45}
47 46
48__access(write_only, 1, 2) 47__access(write_only, 1, 2)
48#if __has_builtin(__builtin_bzero)
49__diagnose_as_builtin(__builtin_bzero, 1, 2) 49__diagnose_as_builtin(__builtin_bzero, 1, 2)
50#endif
50_FORTIFY_FN(bzero) void bzero(void * _FORTIFY_POS0 __s, size_t __n) 51_FORTIFY_FN(bzero) void bzero(void * _FORTIFY_POS0 __s, size_t __n)
51{ 52{
52 size_t __b = __bos(__s, 0); 53 size_t __b = __bos(__s, 0);
diff --git a/include/unistd.h b/include/unistd.h
index e91f922..57f0d0c 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -42,7 +42,6 @@ extern "C" {
42#undef write 42#undef write
43 43
44__access(write_only, 2, 3) 44__access(write_only, 2, 3)
45__diagnose_as_builtin(__builtin_confstr, 1, 2, 3)
46_FORTIFY_FN(confstr) size_t confstr(int __n, char * _FORTIFY_POS0 __s, size_t __l) 45_FORTIFY_FN(confstr) size_t confstr(int __n, char * _FORTIFY_POS0 __s, size_t __l)
47{ 46{
48 size_t __b = __bos(__s, 0); 47 size_t __b = __bos(__s, 0);
@@ -54,7 +53,6 @@ _FORTIFY_FN(confstr) size_t confstr(int __n, char * _FORTIFY_POS0 __s, size_t __
54} 53}
55 54
56__access(write_only, 1, 2) 55__access(write_only, 1, 2)
57__diagnose_as_builtin(__builtin_getcwd, 1, 2)
58_FORTIFY_FN(getcwd) char *getcwd(char * _FORTIFY_POS0 __s, size_t __l) 56_FORTIFY_FN(getcwd) char *getcwd(char * _FORTIFY_POS0 __s, size_t __l)
59{ 57{
60 size_t __b = __bos(__s, 0); 58 size_t __b = __bos(__s, 0);
@@ -67,7 +65,6 @@ _FORTIFY_FN(getcwd) char *getcwd(char * _FORTIFY_POS0 __s, size_t __l)
67#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 65#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
68#undef getdomainname 66#undef getdomainname
69__access(write_only, 1, 2) 67__access(write_only, 1, 2)
70__diagnose_as_builtin(__builtin_getdomainname, 1, 2)
71_FORTIFY_FN(getdomainname) int getdomainname(char * _FORTIFY_POS0 __s, size_t __l) 68_FORTIFY_FN(getdomainname) int getdomainname(char * _FORTIFY_POS0 __s, size_t __l)
72{ 69{
73 size_t __b = __bos(__s, 0); 70 size_t __b = __bos(__s, 0);
@@ -78,7 +75,6 @@ _FORTIFY_FN(getdomainname) int getdomainname(char * _FORTIFY_POS0 __s, size_t __
78} 75}
79#endif 76#endif
80 77
81__diagnose_as_builtin(__builtin_getgroups, 1, 2)
82_FORTIFY_FN(getgroups) int getgroups(int __l, gid_t * _FORTIFY_POS0 __s) 78_FORTIFY_FN(getgroups) int getgroups(int __l, gid_t * _FORTIFY_POS0 __s)
83{ 79{
84 size_t __b = __bos(__s, 0); 80 size_t __b = __bos(__s, 0);
@@ -89,7 +85,6 @@ _FORTIFY_FN(getgroups) int getgroups(int __l, gid_t * _FORTIFY_POS0 __s)
89} 85}
90 86
91__access(write_only, 1, 2) 87__access(write_only, 1, 2)
92__diagnose_as_builtin(__builtin_gethostname, 1, 2)
93_FORTIFY_FN(gethostname) int gethostname(char * _FORTIFY_POS0 __s, size_t __l) 88_FORTIFY_FN(gethostname) int gethostname(char * _FORTIFY_POS0 __s, size_t __l)
94{ 89{
95 size_t __b = __bos(__s, 0); 90 size_t __b = __bos(__s, 0);
@@ -100,7 +95,6 @@ _FORTIFY_FN(gethostname) int gethostname(char * _FORTIFY_POS0 __s, size_t __l)
100} 95}
101 96
102__access(write_only, 1, 2) 97__access(write_only, 1, 2)
103__diagnose_as_builtin(__builtin_getlogin_r, 1, 2)
104_FORTIFY_FN(getlogin_r) int getlogin_r(char * _FORTIFY_POS0 __s, size_t __l) 98_FORTIFY_FN(getlogin_r) int getlogin_r(char * _FORTIFY_POS0 __s, size_t __l)
105{ 99{
106 size_t __b = __bos(__s, 0); 100 size_t __b = __bos(__s, 0);
@@ -110,7 +104,6 @@ _FORTIFY_FN(getlogin_r) int getlogin_r(char * _FORTIFY_POS0 __s, size_t __l)
110 return __orig_getlogin_r(__s, __l); 104 return __orig_getlogin_r(__s, __l);
111} 105}
112 106
113__diagnose_as_builtin(__builtin_pread, 1, 2, 3, 4)
114_FORTIFY_FN(pread) ssize_t pread(int __f, void * _FORTIFY_POS0 __s, 107_FORTIFY_FN(pread) ssize_t pread(int __f, void * _FORTIFY_POS0 __s,
115 size_t __n, off_t __o) 108 size_t __n, off_t __o)
116{ 109{
@@ -122,7 +115,6 @@ _FORTIFY_FN(pread) ssize_t pread(int __f, void * _FORTIFY_POS0 __s,
122} 115}
123 116
124__access(write_only, 2, 3) 117__access(write_only, 2, 3)
125__diagnose_as_builtin(__builtin_read, 1, 2, 3)
126_FORTIFY_FN(read) ssize_t read(int __f, void * _FORTIFY_POS0 __s, size_t __n) 118_FORTIFY_FN(read) ssize_t read(int __f, void * _FORTIFY_POS0 __s, size_t __n)
127{ 119{
128 size_t __b = __bos(__s, 0); 120 size_t __b = __bos(__s, 0);
@@ -133,7 +125,6 @@ _FORTIFY_FN(read) ssize_t read(int __f, void * _FORTIFY_POS0 __s, size_t __n)
133} 125}
134 126
135__access(write_only, 2, 3) 127__access(write_only, 2, 3)
136__diagnose_as_builtin(__builtin_readlink, 1, 2, 3)
137_FORTIFY_FN(readlink) ssize_t readlink(const char *__p, 128_FORTIFY_FN(readlink) ssize_t readlink(const char *__p,
138 char * _FORTIFY_POS0 __s, size_t __n) 129 char * _FORTIFY_POS0 __s, size_t __n)
139{ 130{
@@ -145,7 +136,6 @@ _FORTIFY_FN(readlink) ssize_t readlink(const char *__p,
145} 136}
146 137
147__access(write_only, 3, 4) 138__access(write_only, 3, 4)
148__diagnose_as_builtin(__builtin_readlinkat, 1, 2, 3, 4)
149_FORTIFY_FN(readlinkat) ssize_t readlinkat(int __f, const char *__p, 139_FORTIFY_FN(readlinkat) ssize_t readlinkat(int __f, const char *__p,
150 char * _FORTIFY_POS0 __s, size_t __n) 140 char * _FORTIFY_POS0 __s, size_t __n)
151{ 141{
@@ -157,7 +147,6 @@ _FORTIFY_FN(readlinkat) ssize_t readlinkat(int __f, const char *__p,
157} 147}
158 148
159__access(write_only, 2, 3) 149__access(write_only, 2, 3)
160__diagnose_as_builtin(__builtin_ttyname_r, 1, 2, 3)
161_FORTIFY_FN(ttyname_r) int ttyname_r(int __f, char * _FORTIFY_POS0 __s, 150_FORTIFY_FN(ttyname_r) int ttyname_r(int __f, char * _FORTIFY_POS0 __s,
162 size_t __n) 151 size_t __n)
163{ 152{
@@ -169,7 +158,6 @@ _FORTIFY_FN(ttyname_r) int ttyname_r(int __f, char * _FORTIFY_POS0 __s,
169} 158}
170 159
171__access(read_only, 2, 3) 160__access(read_only, 2, 3)
172__diagnose_as_builtin(__builtin_write, 1, 2, 3)
173_FORTIFY_FN(write) ssize_t write(int __f, const void * _FORTIFY_POS0 __s, 161_FORTIFY_FN(write) ssize_t write(int __f, const void * _FORTIFY_POS0 __s,
174 size_t __n) 162 size_t __n)
175{ 163{
@@ -180,7 +168,6 @@ _FORTIFY_FN(write) ssize_t write(int __f, const void * _FORTIFY_POS0 __s,
180 return __orig_write(__f, __s, __n); 168 return __orig_write(__f, __s, __n);
181} 169}
182 170
183__diagnose_as_builtin(__builtin_pwrite, 1, 2, 3, 4)
184_FORTIFY_FN(pwrite) ssize_t pwrite(int __f, const void * _FORTIFY_POS0 __s, 171_FORTIFY_FN(pwrite) ssize_t pwrite(int __f, const void * _FORTIFY_POS0 __s,
185 size_t __n, off_t __o) 172 size_t __n, off_t __o)
186{ 173{
diff --git a/include/wchar.h b/include/wchar.h
index 4ca49e8..dc73fab 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -56,7 +56,6 @@ extern "C" {
56#undef wmemmove 56#undef wmemmove
57#undef wmemset 57#undef wmemset
58 58
59__diagnose_as_builtin(__builtin_fgetws, 1, 2, 3)
60_FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t * _FORTIFY_POS0 __s, 59_FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t * _FORTIFY_POS0 __s,
61 int __n, FILE *__f) 60 int __n, FILE *__f)
62{ 61{
@@ -70,7 +69,6 @@ _FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t * _FORTIFY_POS0 __s,
70#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ 69#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
71 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 70 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
72#undef mbsnrtowcs 71#undef mbsnrtowcs
73__diagnose_as_builtin(__builtin_mbsnrtowcs, 1, 2, 3, 4, 5)
74_FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t * _FORTIFY_POS0 __d, 72_FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t * _FORTIFY_POS0 __d,
75 const char **__s, size_t __n, 73 const char **__s, size_t __n,
76 size_t __wn, mbstate_t *__st) 74 size_t __wn, mbstate_t *__st)
@@ -92,7 +90,6 @@ _FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t * _FORTIFY_POS0 __d,
92} 90}
93#endif 91#endif
94 92
95__diagnose_as_builtin(__builtin_mbsrtowcs, 1, 2, 3, 4)
96_FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t * _FORTIFY_POS0 __d, 93_FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t * _FORTIFY_POS0 __d,
97 const char **__s, size_t __wn, 94 const char **__s, size_t __wn,
98 mbstate_t *__st) 95 mbstate_t *__st)
@@ -107,7 +104,6 @@ _FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t * _FORTIFY_POS0 __d,
107 return __r; 104 return __r;
108} 105}
109 106
110__diagnose_as_builtin(__builtin_mbstowcs, 1, 2, 3)
111_FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t * _FORTIFY_POS0 __ws, 107_FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t * _FORTIFY_POS0 __ws,
112 const char *__s, size_t __wn) 108 const char *__s, size_t __wn)
113{ 109{
@@ -120,7 +116,6 @@ _FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t * _FORTIFY_POS0 __ws,
120 116
121/* FIXME clang */ 117/* FIXME clang */
122#ifndef __clang__ 118#ifndef __clang__
123__diagnose_as_builtin(__builtin_wcrtomb, 1, 2, 3)
124_FORTIFY_FN(wcrtomb) size_t wcrtomb(char * __s, wchar_t __w, mbstate_t *__st) 119_FORTIFY_FN(wcrtomb) size_t wcrtomb(char * __s, wchar_t __w, mbstate_t *__st)
125{ 120{
126 if (__s && MB_LEN_MAX > __bos(__s, 2)) { 121 if (__s && MB_LEN_MAX > __bos(__s, 2)) {
@@ -139,7 +134,6 @@ _FORTIFY_FN(wcrtomb) size_t wcrtomb(char * __s, wchar_t __w, mbstate_t *__st)
139} 134}
140#endif 135#endif
141 136
142__diagnose_as_builtin(__builtin_wcscat, 1, 2)
143_FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t * _FORTIFY_POS0 __d, 137_FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t * _FORTIFY_POS0 __d,
144 const wchar_t *__s) 138 const wchar_t *__s)
145{ 139{
@@ -150,7 +144,6 @@ _FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t * _FORTIFY_POS0 __d,
150 return __orig_wcscat(__d, __s); 144 return __orig_wcscat(__d, __s);
151} 145}
152 146
153__diagnose_as_builtin(__builtin_wcscpy, 1, 2)
154_FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t * _FORTIFY_POS0 __d, 147_FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t * _FORTIFY_POS0 __d,
155 const wchar_t *__s) 148 const wchar_t *__s)
156{ 149{
@@ -161,7 +154,6 @@ _FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t * _FORTIFY_POS0 __d,
161 return __orig_wcscpy(__d, __s); 154 return __orig_wcscpy(__d, __s);
162} 155}
163 156
164__diagnose_as_builtin(__builtin_wcsncat, 1, 2, 3)
165_FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t * _FORTIFY_POS0 __d, 157_FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t * _FORTIFY_POS0 __d,
166 const wchar_t *__s, size_t __n) 158 const wchar_t *__s, size_t __n)
167{ 159{
@@ -179,7 +171,6 @@ _FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t * _FORTIFY_POS0 __d,
179 return __orig_wcsncat(__d, __s, __n); 171 return __orig_wcsncat(__d, __s, __n);
180} 172}
181 173
182__diagnose_as_builtin(__builtin_wcsncpy, 1, 2, 3)
183_FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t * _FORTIFY_POS0 __d, 174_FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t * _FORTIFY_POS0 __d,
184 const wchar_t *__s, size_t __n) 175 const wchar_t *__s, size_t __n)
185{ 176{
@@ -193,7 +184,6 @@ _FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t * _FORTIFY_POS0 __d,
193#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ 184#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
194 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 185 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
195#undef wcsnrtombs 186#undef wcsnrtombs
196__diagnose_as_builtin(__builtin_wcsntombs, 1, 2, 3, 4, 5)
197_FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char * _FORTIFY_POS0 __d, 187_FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char * _FORTIFY_POS0 __d,
198 const wchar_t **__s, size_t __wn, 188 const wchar_t **__s, size_t __wn,
199 size_t __n, mbstate_t *__st) 189 size_t __n, mbstate_t *__st)
@@ -215,7 +205,6 @@ _FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char * _FORTIFY_POS0 __d,
215} 205}
216#endif 206#endif
217 207
218__diagnose_as_builtin(__builtin_wcsrtombs, 1, 2, 3, 4)
219_FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char * _FORTIFY_POS0 __d, 208_FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char * _FORTIFY_POS0 __d,
220 const wchar_t **__s, size_t __n, 209 const wchar_t **__s, size_t __n,
221 mbstate_t *__st) 210 mbstate_t *__st)
@@ -230,7 +219,6 @@ _FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char * _FORTIFY_POS0 __d,
230} 219}
231 220
232__access(write_only, 1, 3) 221__access(write_only, 1, 3)
233__diagnose_as_builtin(__builtin_wcstombs, 1, 2, 3)
234_FORTIFY_FN(wcstombs) size_t wcstombs(char * _FORTIFY_POS0 __s, 222_FORTIFY_FN(wcstombs) size_t wcstombs(char * _FORTIFY_POS0 __s,
235 const wchar_t *__ws, size_t __n) 223 const wchar_t *__ws, size_t __n)
236{ 224{
@@ -241,7 +229,6 @@ _FORTIFY_FN(wcstombs) size_t wcstombs(char * _FORTIFY_POS0 __s,
241 return __orig_wcstombs(__s, __ws, __n); 229 return __orig_wcstombs(__s, __ws, __n);
242} 230}
243 231
244__diagnose_as_builtin(__builtin_wctomb, 1, 2)
245_FORTIFY_FN(wctomb) int wctomb(char * _FORTIFY_POS0 __s, wchar_t __w) 232_FORTIFY_FN(wctomb) int wctomb(char * _FORTIFY_POS0 __s, wchar_t __w)
246{ 233{
247 size_t __b = __bos(__s, 0); 234 size_t __b = __bos(__s, 0);
@@ -251,7 +238,6 @@ _FORTIFY_FN(wctomb) int wctomb(char * _FORTIFY_POS0 __s, wchar_t __w)
251 return __orig_wctomb(__s, __w); 238 return __orig_wctomb(__s, __w);
252} 239}
253 240
254__diagnose_as_builtin(__builtin_wmemcpy, 1, 2, 3)
255_FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t * _FORTIFY_POS0 __d, 241_FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t * _FORTIFY_POS0 __d,
256 const wchar_t *__s, size_t __n) 242 const wchar_t *__s, size_t __n)
257{ 243{
@@ -262,7 +248,6 @@ _FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t * _FORTIFY_POS0 __d,
262 return __orig_wmemcpy(__d, __s, __n); 248 return __orig_wmemcpy(__d, __s, __n);
263} 249}
264 250
265__diagnose_as_builtin(__builtin_wmemmove, 1, 2, 3)
266_FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t * _FORTIFY_POS0 __d, 251_FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t * _FORTIFY_POS0 __d,
267 const wchar_t *__s, size_t __n) 252 const wchar_t *__s, size_t __n)
268{ 253{
@@ -273,7 +258,6 @@ _FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t * _FORTIFY_POS0 __d,
273 return __orig_wmemmove(__d, __s, __n); 258 return __orig_wmemmove(__d, __s, __n);
274} 259}
275 260
276__diagnose_as_builtin(__builtin_wmemset, 1, 2, 3)
277_FORTIFY_FN(wmemset) wchar_t *wmemset(wchar_t * _FORTIFY_POS0 __s, 261_FORTIFY_FN(wmemset) wchar_t *wmemset(wchar_t * _FORTIFY_POS0 __s,
278 wchar_t __c, size_t __n) 262 wchar_t __c, size_t __n)
279{ 263{