pgsql: Avoid possibly-unsafe use of Windows' FormatMessage() function. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Avoid possibly-unsafe use of Windows' FormatMessage() function.
Date
Msg-id E1akvzt-00043e-CR@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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.

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/6cd30292bfc38edcae0c1d9c127265cfe665a569

Modified Files
--------------
src/backend/libpq/auth.c        | 4 +++-
src/backend/port/win32/socket.c | 4 +++-
src/interfaces/libpq/fe-auth.c  | 4 +++-
src/port/dirmod.c               | 8 ++++++--
4 files changed, 15 insertions(+), 5 deletions(-)


pgsql-committers by date:

Previous
From: Teodor Sigaev
Date:
Subject: pgsql: Fix support of digits in email/hostnames.
Next
From: Tom Lane
Date:
Subject: pgsql: Avoid possibly-unsafe use of Windows' FormatMessage() function.