From 7eb28b59c7665654255640e3fac4ccd5a9e1cbab Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Tue, 18 Mar 2014 17:03:38 -0700 Subject: [PATCH] FORTIFY_SOURCE: don't define s?printf macros if already defined Clang specific: Don't #define sprintf and snprintf macros if they are already defined. Change-Id: I30fc507d898377e1b8a57a65a147926229e0f9e2 --- libc/include/stdio.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libc/include/stdio.h b/libc/include/stdio.h index 6f8f92ef3..470d37770 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -393,8 +393,10 @@ int vsprintf(char *dest, const char *format, __va_list ap) } #if defined(__clang__) -#define __wrap_snprintf(dest, size, ...) __builtin___snprintf_chk(dest, size, 0, __bos(dest), __VA_ARGS__) -#define snprintf(...) __wrap_snprintf(__VA_ARGS__) + #if !defined(snprintf) + #define __wrap_snprintf(dest, size, ...) __builtin___snprintf_chk(dest, size, 0, __bos(dest), __VA_ARGS__) + #define snprintf(...) __wrap_snprintf(__VA_ARGS__) + #endif #else __BIONIC_FORTIFY_INLINE __printflike(3, 4) @@ -406,8 +408,10 @@ int snprintf(char *dest, size_t size, const char *format, ...) #endif #if defined(__clang__) -#define __wrap_sprintf(dest, ...) __builtin___sprintf_chk(dest, 0, __bos(dest), __VA_ARGS__) -#define sprintf(...) __wrap_sprintf(__VA_ARGS__) + #if !defined(sprintf) + #define __wrap_sprintf(dest, ...) __builtin___sprintf_chk(dest, 0, __bos(dest), __VA_ARGS__) + #define sprintf(...) __wrap_sprintf(__VA_ARGS__) + #endif #else __BIONIC_FORTIFY_INLINE __printflike(2, 3)