diff options
author | Andrew Dunstan | 2006-11-28 01:12:34 +0000 |
---|---|---|
committer | Andrew Dunstan | 2006-11-28 01:12:34 +0000 |
commit | 9b6b669ec088bd5159c466e2ea51cee8b43668e0 (patch) | |
tree | fd5d2a994d8a08e7961f23a9c77fefe5b89c64a6 | |
parent | 79e57bbb6f1eb250eab4bef9c4a83ba0a06c667c (diff) |
protect vfprintf from hijacking by Windows gettext just like other members of the *printf family.
-rw-r--r-- | src/include/port.h | 6 | ||||
-rw-r--r-- | src/port/snprintf.c | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/include/port.h b/src/include/port.h index 54b163de28..e46b07d12c 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -145,6 +145,9 @@ extern unsigned char pg_tolower(unsigned char ch); #ifdef sprintf #undef sprintf #endif +#ifdef vfprintf +#undef vfprintf +#endif #ifdef fprintf #undef fprintf #endif @@ -161,6 +164,7 @@ extern int pg_sprintf(char *str, const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(printf, 2, 3))); +extern int pg_vfprintf(FILE * stream, const char *fmt, va_list args); extern int pg_fprintf(FILE *stream, const char *fmt,...) /* This extension allows gcc to check the format string */ @@ -179,12 +183,14 @@ __attribute__((format(printf, 1, 2))); #define vsnprintf(...) pg_vsnprintf(__VA_ARGS__) #define snprintf(...) pg_snprintf(__VA_ARGS__) #define sprintf(...) pg_sprintf(__VA_ARGS__) +#define vfprintf(...) pg_vfprintf(__VA_ARGS__) #define fprintf(...) pg_fprintf(__VA_ARGS__) #define printf(...) pg_printf(__VA_ARGS__) #else #define vsnprintf pg_vsnprintf #define snprintf pg_snprintf #define sprintf pg_sprintf +#define vfprintf pg_vfprintf #define fprintf pg_fprintf #define printf pg_printf #endif diff --git a/src/port/snprintf.c b/src/port/snprintf.c index 4f7881ff45..30a54ebf73 100644 --- a/src/port/snprintf.c +++ b/src/port/snprintf.c @@ -99,6 +99,7 @@ #undef vsnprintf #undef snprintf #undef sprintf +#undef vfprintf #undef fprintf #undef printf @@ -209,7 +210,7 @@ pg_sprintf(char *str, const char *fmt,...) return len; } -static int +int pg_vfprintf(FILE *stream, const char *fmt, va_list args) { PrintfTarget target; |