diff options
Diffstat (limited to 'include/stdio.h')
| -rw-r--r-- | include/stdio.h | 86 |
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 |
