Skip to content

Commit 796a3f3

Browse files
committed
protect vfprintf from hijacking by Windows gettext just like other members of the *printf family.
1 parent c15de02 commit 796a3f3

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/include/port.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.105 2006/10/19 20:56:22 tgl Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.106 2006/11/28 01:12:33 adunstan Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -145,6 +145,9 @@ extern unsigned char pg_tolower(unsigned char ch);
145145
#ifdef sprintf
146146
#undef sprintf
147147
#endif
148+
#ifdef vfprintf
149+
#undef vfprintf
150+
#endif
148151
#ifdef fprintf
149152
#undef fprintf
150153
#endif
@@ -161,6 +164,7 @@ extern int
161164
pg_sprintf(char *str, const char *fmt,...)
162165
/* This extension allows gcc to check the format string */
163166
__attribute__((format(printf, 2, 3)));
167+
extern int pg_vfprintf(FILE * stream, const char *fmt, va_list args);
164168
extern int
165169
pg_fprintf(FILE *stream, const char *fmt,...)
166170
/* This extension allows gcc to check the format string */
@@ -179,12 +183,14 @@ __attribute__((format(printf, 1, 2)));
179183
#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__)
180184
#define snprintf(...) pg_snprintf(__VA_ARGS__)
181185
#define sprintf(...) pg_sprintf(__VA_ARGS__)
186+
#define vfprintf(...) pg_vfprintf(__VA_ARGS__)
182187
#define fprintf(...) pg_fprintf(__VA_ARGS__)
183188
#define printf(...) pg_printf(__VA_ARGS__)
184189
#else
185190
#define vsnprintf pg_vsnprintf
186191
#define snprintf pg_snprintf
187192
#define sprintf pg_sprintf
193+
#define vfprintf pg_vfprintf
188194
#define fprintf pg_fprintf
189195
#define printf pg_printf
190196
#endif

src/port/snprintf.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232
* SUCH DAMAGE.
3333
*
34-
* $PostgreSQL: pgsql/src/port/snprintf.c,v 1.32 2006/10/04 00:30:14 momjian Exp $
34+
* $PostgreSQL: pgsql/src/port/snprintf.c,v 1.33 2006/11/28 01:12:34 adunstan Exp $
3535
*/
3636

3737
#include "c.h"
@@ -99,6 +99,7 @@
9999
#undef vsnprintf
100100
#undef snprintf
101101
#undef sprintf
102+
#undef vfprintf
102103
#undef fprintf
103104
#undef printf
104105

@@ -209,7 +210,7 @@ pg_sprintf(char *str, const char *fmt,...)
209210
return len;
210211
}
211212

212-
static int
213+
int
213214
pg_vfprintf(FILE *stream, const char *fmt, va_list args)
214215
{
215216
PrintfTarget target;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy