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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Avoid possibly-unsafe use of Windows' FormatMessage() function.
Date: 2016-03-29 15:56:01
Message-ID: E1akvzt-00043V-C2@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/491e847380740dac54d4ecae820261bbaa8aee44

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2016-03-29 16:11:59 pgsql: pgbench: Remove \setrandom.
Previous Message Teodor Sigaev 2016-03-29 15:29:20 pgsql: Fix support of digits in email/hostnames.