pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@postgresql.org
Subject: pgsql: Add error-throwing wrappers for the printf family of functions.
Date: Mon, 18 May 2015 14:04:03 +0000
Message-ID: <E1YuLeF-00067e-2C@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Add error-throwing wrappers for the printf family of functions.

All known standard library implementations of these functions can fail
with ENOMEM.  A caller neglecting to check for failure would experience
missing output, information exposure, or a crash.  Check return values
within wrappers and code, currently just snprintf.c, that bypasses the
wrappers.  The wrappers do not return after an error, so their callers
need not check.  Back-patch to 9.0 (all supported versions).

Popular free software standard library implementations do take pains to
bypass malloc() in simple cases, but they risk ENOMEM for floating point
numbers, positional arguments, large field widths, and large precisions.
No specification demands such caution, so this commit regards every call
to a printf family function as a potential threat.

Injecting the wrappers implicitly is a compromise between patch scope
and design goals.  I would prefer to edit each call site to name a
wrapper explicitly.  libpq and the ECPG libraries would, ideally, convey
errors to the caller rather than abort().  All that would be painfully
invasive for a back-patched security fix, hence this compromise.

Security: CVE-2015-3166

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/b08c7aff708b403298f8e006cce0e1e82349e88e

Modified Files
--------------
src/include/port.h                        |   80 ++++++++++-----
src/interfaces/ecpg/compatlib/Makefile    |    1 +
src/interfaces/ecpg/ecpglib/.gitignore    |    1 +
src/interfaces/ecpg/ecpglib/Makefile      |    6 +-
src/interfaces/ecpg/pgtypeslib/.gitignore |    1 +
src/interfaces/ecpg/pgtypeslib/Makefile   |    6 +-
src/interfaces/libpq/.gitignore           |    1 +
src/interfaces/libpq/Makefile             |    6 +-
src/interfaces/libpq/bcc32.mak            |    7 ++
src/interfaces/libpq/win32.mak            |    7 ++
src/port/Makefile                         |    2 +-
src/port/snprintf.c                       |   94 +++++++++--------
src/port/syswrap.c                        |  155 +++++++++++++++++++++++++++++
src/tools/msvc/Mkvcbuild.pm               |    2 +-
14 files changed, 292 insertions(+), 77 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: <E1YuLeF-00067e-2C@gemulon.postgresql.org>
Permalink:  ../E1YuLeF-00067e-2C@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1YuLeF-00067e-2C@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: noah@leadboat.com
  Subject: Re: pgsql: Add error-throwing wrappers for the printf family of functions.
  In-Reply-To: <E1YuLeF-00067e-2C@gemulon.postgresql.org>
  References: <E1YuLeF-00067e-2C@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