diff options
Diffstat (limited to 'include/stdio.h')
| -rw-r--r-- | include/stdio.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/include/stdio.h b/include/stdio.h index c6817fa..abdef6c 100644 --- a/include/stdio.h +++ b/include/stdio.h | |||
| @@ -220,6 +220,26 @@ _FORTIFY_FN(vprintf) int vprintf(const char *__f, __builtin_va_list __v) | |||
| 220 | return __orig_vprintf(__f, __v); | 220 | return __orig_vprintf(__f, __v); |
| 221 | #endif | 221 | #endif |
| 222 | } | 222 | } |
| 223 | |||
| 224 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | ||
| 225 | #undef vasprintf | ||
| 226 | #if __has_builtin(__builtin_vasprintf) | ||
| 227 | __diagnose_as_builtin(__builtin_vasprintf, 1, 2, 3) | ||
| 228 | #endif | ||
| 229 | _FORTIFY_FN(vasprintf) int vasprintf(char **restrict strp, const char *restrict fmt, __builtin_va_list ap) | ||
| 230 | { | ||
| 231 | #if __has_builtin(__builtin___vasprintf_chk) && USE_NATIVE_CHK | ||
| 232 | return __builtin___vasprintf_chk(_FORTIFY_SOURCE, strp, fmt, ap); | ||
| 233 | #else | ||
| 234 | int ret = __orig_vasprintf(strp, fmt, ap); | ||
| 235 | if (ret < 0) | ||
| 236 | *strp = NULL; | ||
| 237 | return ret; | ||
| 238 | #endif | ||
| 239 | } | ||
| 240 | |||
| 241 | |||
| 242 | #endif // defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | ||
| 223 | #endif // __clang__ | 243 | #endif // __clang__ |
| 224 | 244 | ||
| 225 | 245 | ||
| @@ -312,6 +332,28 @@ _FORTIFY_FN(fprintf) int fprintf(FILE *__s, const char *__f, ...) | |||
| 312 | #endif | 332 | #endif |
| 313 | } | 333 | } |
| 314 | 334 | ||
| 335 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | ||
| 336 | #ifndef __clang__ | ||
| 337 | #undef asprintf | ||
| 338 | __fh_access(read_only, 2) | ||
| 339 | __fh_format(printf, 2, 0) | ||
| 340 | #if __has_builtin(__builtin_asprintf) | ||
| 341 | __diagnose_as_builtin(__builtin_asprintf, 2, 3) | ||
| 342 | #endif | ||
| 343 | _FORTIFY_FN(asprintf) int asprintf(char **restrict strp, const char *restrict fmt, ...) | ||
| 344 | { | ||
| 345 | #if __has_builtin(__builtin___asprintf_chk) && USE_NATIVE_CHK | ||
| 346 | return __builtin___asprintf_chk(_FORTIFY_SOURCE, strp, fmt, __builtin_va_arg_pack()); | ||
| 347 | #else | ||
| 348 | int ret = __orig_asprintf(strp, fmt, __builtin_va_arg_pack()); | ||
| 349 | if (ret<0) | ||
| 350 | *strp = NULL; | ||
| 351 | return ret; | ||
| 352 | #endif | ||
| 353 | } | ||
| 354 | #endif // __clang__ | ||
| 355 | #endif | ||
| 356 | |||
| 315 | #pragma GCC diagnostic pop | 357 | #pragma GCC diagnostic pop |
| 316 | #endif /* __has_builtin(__builtin_va_arg_pack) */ | 358 | #endif /* __has_builtin(__builtin_va_arg_pack) */ |
| 317 | 359 | ||
