1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Fix omissions in snprintf.c's coverage of standard *printf functions.

A warning on a NetBSD box revealed to me that pg_waldump/compat.c
is using vprintf(), which snprintf.c did not provide coverage for.
This is not good if we want to have uniform *printf behavior, and
it's pretty silly to omit when it's a one-line function.

I also noted that snprintf.c has pg_vsprintf() but for some reason
it was not exposed to the outside world, creating another way in
which code might accidentally invoke the platform *printf family.

Let's just make sure that we replace all eight of the POSIX-standard
printf family.

Also, upgrade plperl.h and plpython.h to make sure that they do
their undefine/redefine rain dance for all eight, not some random
maybe-sufficient subset thereof.
This commit is contained in:
Tom Lane
2018-10-08 19:15:55 -04:00
parent 82ff0cc91d
commit 7767aadd94
4 changed files with 93 additions and 14 deletions

View File

@@ -152,6 +152,9 @@ extern unsigned char pg_ascii_tolower(unsigned char ch);
#ifdef snprintf
#undef snprintf
#endif
#ifdef vsprintf
#undef vsprintf
#endif
#ifdef sprintf
#undef sprintf
#endif
@@ -161,15 +164,20 @@ extern unsigned char pg_ascii_tolower(unsigned char ch);
#ifdef fprintf
#undef fprintf
#endif
#ifdef vprintf
#undef vprintf
#endif
#ifdef printf
#undef printf
#endif
extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
extern int pg_snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3, 4);
extern int pg_vsprintf(char *str, const char *fmt, va_list args);
extern int pg_sprintf(char *str, const char *fmt,...) pg_attribute_printf(2, 3);
extern int pg_vfprintf(FILE *stream, const char *fmt, va_list args);
extern int pg_fprintf(FILE *stream, const char *fmt,...) pg_attribute_printf(2, 3);
extern int pg_vprintf(const char *fmt, va_list args);
extern int pg_printf(const char *fmt,...) pg_attribute_printf(1, 2);
/*
@@ -182,9 +190,11 @@ extern int pg_printf(const char *fmt,...) pg_attribute_printf(1, 2);
*/
#define vsnprintf pg_vsnprintf
#define snprintf pg_snprintf
#define vsprintf pg_vsprintf
#define sprintf pg_sprintf
#define vfprintf pg_vfprintf
#define fprintf pg_fprintf
#define vprintf pg_vprintf
#define printf(...) pg_printf(__VA_ARGS__)
/* This is also provided by snprintf.c */