diff options
author | Nick Kralevich <nnk@google.com> | 2012-06-12 08:50:57 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-06-12 08:50:57 -0700 |
commit | c2f1d215b1786520fa8c371caa97f062e0bfb513 (patch) | |
tree | 5fb4e8d1f40d5febb9b605d230654d60af8ed731 /libc/include/stdio.h | |
parent | f525fb525b19e76ac9438b7fddeaa3312517a092 (diff) | |
parent | cffdf6693ffb50d2a1258d955a162bca83038f25 (diff) | |
download | android_bionic-c2f1d215b1786520fa8c371caa97f062e0bfb513.tar.gz android_bionic-c2f1d215b1786520fa8c371caa97f062e0bfb513.tar.bz2 android_bionic-c2f1d215b1786520fa8c371caa97f062e0bfb513.zip |
Merge "FORTIFY_SOURCE: add snprintf, vsnprintf"
Diffstat (limited to 'libc/include/stdio.h')
-rw-r--r-- | libc/include/stdio.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libc/include/stdio.h b/libc/include/stdio.h index 8d3d5d71b..cc3270d81 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -458,4 +458,32 @@ int vfdprintf(int, const char*, __va_list); __END_DECLS #endif /* _GNU_SOURCE */ +#if defined(__BIONIC_FORTIFY_INLINE) + +__BIONIC_FORTIFY_INLINE +__attribute__((__format__ (printf, 3, 0))) +__attribute__((__nonnull__ (3))) +int vsnprintf(char *str, size_t size, const char *format, __va_list ap) +{ + return __builtin___vsnprintf_chk(str, size, 0, __builtin_object_size(str, 0), format, ap); +} + +# if !defined(__clang__) +/* + * Clang doesn't have support for __builtin_va_arg_pack() + * http://clang.llvm.org/docs/UsersManual.html#c_unimpl_gcc + */ + +__BIONIC_FORTIFY_INLINE +__attribute__((__format__ (printf, 3, 4))) +__attribute__((__nonnull__ (3))) +int snprintf(char *str, size_t size, const char *format, ...) +{ + return __builtin___snprintf_chk(str, size, 0, __builtin_object_size(str, 0), format, __builtin_va_arg_pack()); +} + +# endif /* !defined(__clang__) */ + +#endif /* defined(__BIONIC_FORTIFY_INLINE) */ + #endif /* _STDIO_H_ */ |