summaryrefslogtreecommitdiff
path: root/include/stdio.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/stdio.h')
-rw-r--r--include/stdio.h86
1 files changed, 43 insertions, 43 deletions
diff --git a/include/stdio.h b/include/stdio.h
index 59ae4ff..c6817fa 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -44,7 +44,7 @@ extern "C" {
44#undef fmemopen 44#undef fmemopen
45#undef popen 45#undef popen
46 46
47__access(read_only, 2) 47__fh_access(read_only, 2)
48#if __has_builtin(__builtin_fdopen) 48#if __has_builtin(__builtin_fdopen)
49__diagnose_as_builtin(__builtin_fdopen, 1, 2) 49__diagnose_as_builtin(__builtin_fdopen, 1, 2)
50#endif 50#endif
@@ -53,7 +53,7 @@ _FORTIFY_FN(fdopen) FILE *fdopen(int __f, const char* _FORTIFY_POS0 __m)
53 return __orig_fdopen(__f, __m); 53 return __orig_fdopen(__f, __m);
54} 54}
55 55
56__malloc(malloc (fclose, 1)) 56__fh_malloc(malloc (fclose, 1))
57#if __has_builtin(__builtin_fmemopen) 57#if __has_builtin(__builtin_fmemopen)
58__diagnose_as_builtin(__builtin_fmemopen, 1, 2, 3) 58__diagnose_as_builtin(__builtin_fmemopen, 1, 2, 3)
59#endif 59#endif
@@ -62,9 +62,9 @@ _FORTIFY_FN(fmemopen) FILE *fmemopen(void* _FORTIFY_POS0 __b, size_t __s, const
62 return __orig_fmemopen(__b, __s, __m); 62 return __orig_fmemopen(__b, __s, __m);
63} 63}
64 64
65__access(read_only, 1) 65__fh_access(read_only, 1)
66__access(read_only, 2) 66__fh_access(read_only, 2)
67__malloc(malloc (pclose, 1)) 67__fh_malloc(malloc (pclose, 1))
68#if __has_builtin(__builtin_popen) 68#if __has_builtin(__builtin_popen)
69__diagnose_as_builtin(__builtin_popen, 1, 2) 69__diagnose_as_builtin(__builtin_popen, 1, 2)
70#endif 70#endif
@@ -75,22 +75,22 @@ _FORTIFY_FN(popen) FILE *popen(const char* _FORTIFY_POS0 __c, const char* _FORTI
75 75
76#endif /* _POSIX_SOURCE || _POSIX_C_SOURCE || _XOPEN_SOURCE || _GNU_SOURCE || _BSD_SOURCE */ 76#endif /* _POSIX_SOURCE || _POSIX_C_SOURCE || _XOPEN_SOURCE || _GNU_SOURCE || _BSD_SOURCE */
77 77
78__access(write_only, 1, 2) 78__fh_access(write_only, 1, 2)
79#if __has_builtin(__builtin_fgets) 79#if __has_builtin(__builtin_fgets)
80__diagnose_as_builtin(__builtin_fgets, 1, 2, 3) 80__diagnose_as_builtin(__builtin_fgets, 1, 2, 3)
81#endif 81#endif
82_FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f) 82_FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f)
83{ 83{
84 __fh_size_t __b = __bos(__s, 0); 84 __fh_size_t __b = __fh_bos(__s, 0);
85 85
86 if ((__fh_size_t)__n > __b) 86 if ((__fh_size_t)__n > __b)
87 __builtin_trap(); 87 __builtin_trap();
88 return __orig_fgets(__s, __n, __f); 88 return __orig_fgets(__s, __n, __f);
89} 89}
90 90
91__access(read_only, 1) 91__fh_access(read_only, 1)
92__access(read_only, 2) 92__fh_access(read_only, 2)
93__malloc(malloc (fclose, 1)) 93__fh_malloc(malloc (fclose, 1))
94#if __has_builtin(__builtin_fopen) 94#if __has_builtin(__builtin_fopen)
95__diagnose_as_builtin(__builtin_fopen, 1, 2) 95__diagnose_as_builtin(__builtin_fopen, 1, 2)
96#endif 96#endif
@@ -99,14 +99,14 @@ _FORTIFY_FN(fopen) FILE *fopen(const char* _FORTIFY_POS0 __p, const char* _FORTI
99 return __orig_fopen(__p, __m); 99 return __orig_fopen(__p, __m);
100} 100}
101 101
102__access(write_only, 1) 102__fh_access(write_only, 1)
103#if __has_builtin(__builtin_fread) 103#if __has_builtin(__builtin_fread)
104__diagnose_as_builtin(__builtin_fread, 1, 2, 3, 4) 104__diagnose_as_builtin(__builtin_fread, 1, 2, 3, 4)
105#endif 105#endif
106_FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n, 106_FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n,
107 size_t __m, FILE *__f) 107 size_t __m, FILE *__f)
108{ 108{
109 __fh_size_t __b = __bos(__d, 0); 109 __fh_size_t __b = __fh_bos(__d, 0);
110 110
111 if (__bmo(__n, __m)) 111 if (__bmo(__n, __m))
112 __builtin_trap(); 112 __builtin_trap();
@@ -115,14 +115,14 @@ _FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n,
115 return __orig_fread(__d, __n, __m, __f); 115 return __orig_fread(__d, __n, __m, __f);
116} 116}
117 117
118__access(read_only, 1) 118__fh_access(read_only, 1)
119#if __has_builtin(__builtin_fwrite) 119#if __has_builtin(__builtin_fwrite)
120__diagnose_as_builtin(__builtin_fwrite, 1, 2, 3, 4) 120__diagnose_as_builtin(__builtin_fwrite, 1, 2, 3, 4)
121#endif 121#endif
122_FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n, 122_FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n,
123 size_t __m, FILE *__f) 123 size_t __m, FILE *__f)
124{ 124{
125 __fh_size_t __b = __bos(__d, 0); 125 __fh_size_t __b = __fh_bos(__d, 0);
126 126
127 if (__bmo(__n, __m)) 127 if (__bmo(__n, __m))
128 __builtin_trap(); 128 __builtin_trap();
@@ -133,7 +133,7 @@ _FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n,
133 133
134#ifndef __clang__ /* FIXME */ 134#ifndef __clang__ /* FIXME */
135#undef tmpfile 135#undef tmpfile
136__malloc(malloc (fclose, 1)) 136__fh_malloc(malloc (fclose, 1))
137#if __has_builtin(__builtin_tmpfile) 137#if __has_builtin(__builtin_tmpfile)
138__diagnose_as_builtin(__builtin_tmpfile) 138__diagnose_as_builtin(__builtin_tmpfile)
139#endif 139#endif
@@ -143,9 +143,9 @@ _FORTIFY_FN(tmpfile) FILE *tmpfile(void)
143} 143}
144#endif 144#endif
145 145
146__access(read_write, 1, 2) 146__fh_access(read_write, 1, 2)
147__access(read_only, 3) 147__fh_access(read_only, 3)
148__format(printf, 3, 0) 148__fh_format(printf, 3, 0)
149#if __has_builtin(__builtin_vsnprintf) 149#if __has_builtin(__builtin_vsnprintf)
150__diagnose_as_builtin(__builtin_vsnprintf, 1, 2, 3, 4) 150__diagnose_as_builtin(__builtin_vsnprintf, 1, 2, 3, 4)
151#endif 151#endif
@@ -153,9 +153,9 @@ _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n,
153 const char *__f, __builtin_va_list __v) 153 const char *__f, __builtin_va_list __v)
154{ 154{
155#if __has_builtin(__builtin___vsnprintf_chk) && USE_NATIVE_CHK 155#if __has_builtin(__builtin___vsnprintf_chk) && USE_NATIVE_CHK
156 return __builtin___vsnprintf_chk(__s, __n, _FORTIFY_SOURCE, __bos(__s, 0), __f, __v); 156 return __builtin___vsnprintf_chk(__s, __n, _FORTIFY_SOURCE, __fh_bos(__s, 0), __f, __v);
157#else 157#else
158 __fh_size_t __b = __bos(__s, 0); 158 __fh_size_t __b = __fh_bos(__s, 0);
159 159
160 if (__n > __b) 160 if (__n > __b)
161 __builtin_trap(); 161 __builtin_trap();
@@ -163,9 +163,9 @@ _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n,
163#endif 163#endif
164} 164}
165 165
166__format(printf, 2, 0) 166__fh_format(printf, 2, 0)
167__access(read_write, 1) 167__fh_access(read_write, 1)
168__access(read_only, 2) 168__fh_access(read_only, 2)
169#if __has_builtin(__builtin_vsprintf) 169#if __has_builtin(__builtin_vsprintf)
170__diagnose_as_builtin(__builtin_vsprintf, 1, 2, 3) 170__diagnose_as_builtin(__builtin_vsprintf, 1, 2, 3)
171#endif 171#endif
@@ -173,9 +173,9 @@ _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f,
173 __builtin_va_list __v) 173 __builtin_va_list __v)
174{ 174{
175#if __has_builtin(__builtin___vsprintf_chk) && USE_NATIVE_CHK 175#if __has_builtin(__builtin___vsprintf_chk) && USE_NATIVE_CHK
176 return __builtin___vsprintf_chk(__s, _FORTIFY_SOURCE, __bos(__s, 0), __f, __v); 176 return __builtin___vsprintf_chk(__s, _FORTIFY_SOURCE, __fh_bos(__s, 0), __f, __v);
177#else 177#else
178 __fh_size_t __b = __bos(__s, 0); 178 __fh_size_t __b = __fh_bos(__s, 0);
179 int __r; 179 int __r;
180 180
181 if (__b != (__fh_size_t)-1) { 181 if (__b != (__fh_size_t)-1) {
@@ -193,8 +193,8 @@ _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f,
193#undef vfprintf 193#undef vfprintf
194#undef vprintf 194#undef vprintf
195 195
196__access(read_only, 2) 196__fh_access(read_only, 2)
197__format(printf, 2, 0) 197__fh_format(printf, 2, 0)
198#if __has_builtin(__builtin_vfprintf) 198#if __has_builtin(__builtin_vfprintf)
199__diagnose_as_builtin(__builtin_vfprintf, 2, 3) 199__diagnose_as_builtin(__builtin_vfprintf, 2, 3)
200#endif 200#endif
@@ -207,8 +207,8 @@ _FORTIFY_FN(vfprintf) int vfprintf(FILE * __s, const char *__f, __builtin_va_lis
207#endif 207#endif
208} 208}
209 209
210__access(read_only, 1) 210__fh_access(read_only, 1)
211__format(printf, 1, 0) 211__fh_format(printf, 1, 0)
212#if __has_builtin(__builtin_vprintf) 212#if __has_builtin(__builtin_vprintf)
213__diagnose_as_builtin(__builtin_vprintf, 1, 2) 213__diagnose_as_builtin(__builtin_vprintf, 1, 2)
214#endif 214#endif
@@ -248,16 +248,16 @@ _FORTIFY_FN(vprintf) int vprintf(const char *__f, __builtin_va_list __v)
248#undef printf 248#undef printf
249#undef fprintf 249#undef fprintf
250 250
251__access(read_write, 1, 2) 251__fh_access(read_write, 1, 2)
252__access(read_only, 3) 252__fh_access(read_only, 3)
253__format(printf, 3, 4) 253__fh_format(printf, 3, 4)
254_FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, 254_FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n,
255 const char *__f, ...) 255 const char *__f, ...)
256{ 256{
257#if __has_builtin(__builtin___snprintf_chk) && USE_NATIVE_CHK 257#if __has_builtin(__builtin___snprintf_chk) && USE_NATIVE_CHK
258 return __builtin___snprintf_chk(__s, __n, _FORTIFY_SOURCE, __bos(__s, 0), __f, __builtin_va_arg_pack()); 258 return __builtin___snprintf_chk(__s, __n, _FORTIFY_SOURCE, __fh_bos(__s, 0), __f, __builtin_va_arg_pack());
259#else 259#else
260 __fh_size_t __b = __bos(__s, 0); 260 __fh_size_t __b = __fh_bos(__s, 0);
261 261
262 if (__n > __b) 262 if (__n > __b)
263 __builtin_trap(); 263 __builtin_trap();
@@ -265,15 +265,15 @@ _FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n,
265#endif 265#endif
266} 266}
267 267
268__format(printf, 2, 3) 268__fh_format(printf, 2, 3)
269__access(read_write, 1) 269__fh_access(read_write, 1)
270__access(read_only, 2) 270__fh_access(read_only, 2)
271_FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...) 271_FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...)
272{ 272{
273#if __has_builtin(__builtin___sprintf_chk) && USE_NATIVE_CHK 273#if __has_builtin(__builtin___sprintf_chk) && USE_NATIVE_CHK
274 return __builtin___sprintf_chk(__s, _FORTIFY_SOURCE, __bos(__s, 0), __f, __builtin_va_arg_pack()); 274 return __builtin___sprintf_chk(__s, _FORTIFY_SOURCE, __fh_bos(__s, 0), __f, __builtin_va_arg_pack());
275#else 275#else
276 __fh_size_t __b = __bos(__s, 0); 276 __fh_size_t __b = __fh_bos(__s, 0);
277 int __r; 277 int __r;
278 278
279 if (__b != (__fh_size_t)-1) { 279 if (__b != (__fh_size_t)-1) {
@@ -287,8 +287,8 @@ _FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...)
287#endif 287#endif
288} 288}
289 289
290__format(printf, 1, 2) 290__fh_format(printf, 1, 2)
291__access(read_only, 1) 291__fh_access(read_only, 1)
292_FORTIFY_FN(printf) int printf(const char *__f, ...) 292_FORTIFY_FN(printf) int printf(const char *__f, ...)
293{ 293{
294#if __has_builtin(__builtin___printf_chk) && USE_NATIVE_CHK 294#if __has_builtin(__builtin___printf_chk) && USE_NATIVE_CHK
@@ -298,8 +298,8 @@ _FORTIFY_FN(printf) int printf(const char *__f, ...)
298#endif 298#endif
299} 299}
300 300
301__access(read_only, 2) 301__fh_access(read_only, 2)
302__format(printf, 2, 0) 302__fh_format(printf, 2, 0)
303#if __has_builtin(__builtin_fprintf) 303#if __has_builtin(__builtin_fprintf)
304__diagnose_as_builtin(__builtin_fprintf, 2, 3) 304__diagnose_as_builtin(__builtin_fprintf, 2, 3)
305#endif 305#endif