pgsql: Check return values of sensitive system library calls.

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Check return values of sensitive system library calls.
Date: 2015-05-18 14:04:03
Message-ID: E1YuLeF-00067n-2g@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Check return values of sensitive system library calls.

PostgreSQL already checked the vast majority of these, missing this
handful that nearly cannot fail. If putenv() failed with ENOMEM in
pg_GSS_recvauth(), authentication would proceed with the wrong keytab
file. If strftime() returned zero in cache_locale_time(), using the
unspecified buffer contents could lead to information exposure or a
crash. Back-patch to 9.0 (all supported versions).

Other unchecked calls to these functions, especially those in frontend
code, pose negligible security concern. This patch does not address
them. Nonetheless, it is always better to check return values whose
specification provides for indicating an error.

In passing, fix an off-by-one error in strftime_win32()'s invocation of
WideCharToMultiByte(). Upon retrieving a value of exactly MAX_L10N_DATA
bytes, strftime_win32() would overrun the caller's buffer by one byte.
MAX_L10N_DATA is chosen to exceed the length of every possible value, so
the vulnerable scenario probably does not arise.

Security: CVE-2015-3166

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/9b5e831e342d14caeebece6c705616f10880b00d

Modified Files
--------------
src/backend/libpq/auth.c | 7 ++--
src/backend/utils/adt/pg_locale.c | 74 ++++++++++++++++++++++---------------
2 files changed, 48 insertions(+), 33 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2015-05-18 14:45:26 Re: pgsql: Separate block sampling functions
Previous Message Noah Misch 2015-05-18 14:04:02 pgsql: Add error-throwing wrappers for the printf family of functions.