Avoid possibly-unsafe use of Windows' FormatMessage() function.
authorTom Lane
Tue, 29 Mar 2016 15:54:57 +0000 (11:54 -0400)
committerTom Lane
Tue, 29 Mar 2016 15:54:57 +0000 (11:54 -0400)
commit2fed676c937cdcdfafa72865308b84a7f273e730
treed14b3eb6da39fad4419c4a0406859f58359c8904
parentd77841d1cebd3514603af055f141a84c8e53cbd3
Avoid possibly-unsafe use of Windows' FormatMessage() function.

Whenever this function is used with the FORMAT_MESSAGE_FROM_SYSTEM flag,
it's good practice to include FORMAT_MESSAGE_IGNORE_INSERTS as well.
Otherwise, if the message contains any %n insertion markers, the function
will try to fetch argument strings to substitute --- which we are not
passing, possibly leading to a crash.  This is exactly analogous to the
rule about not giving printf() a format string you're not in control of.

Noted and patched by Christian Ullrich.
Back-patch to all supported branches.
src/backend/libpq/auth.c
src/backend/port/win32/socket.c
src/interfaces/libpq/fe-auth.c
src/port/dirmod.c