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