pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Avoid possibly-unsafe use of Windows' FormatMessage() function.
Date: Tue, 29 Mar 2016 15:56:01 +0000
Message-ID: <E1akvzt-00043V-C2@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


view thread (6+ messages)

Message-ID: <E1akvzt-00043V-C2@gemulon.postgresql.org>
Permalink:  ../E1akvzt-00043V-C2@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1akvzt-00043V-C2@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Avoid possibly-unsafe use of Windows' FormatMessage() function.
  In-Reply-To: <E1akvzt-00043V-C2@gemulon.postgresql.org>
  References: <E1akvzt-00043V-C2@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox