pgsql: Predict integer overflow to avoid buffer overruns.

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Predict integer overflow to avoid buffer overruns.
Date: 2014-02-17 15:05:46
Message-ID: E1WFPlS-0000gi-Kv@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Predict integer overflow to avoid buffer overruns.

Several functions, mostly type input functions, calculated an allocation
size such that the calculation wrapped to a small positive value when
arguments implied a sufficiently-large requirement. Writes past the end
of the inadvertent small allocation followed shortly thereafter.
Coverity identified the path_in() vulnerability; code inspection led to
the rest. In passing, add check_stack_depth() to prevent stack overflow
in related functions.

Back-patch to 8.4 (all supported versions). The non-comment hstore
changes touch code that did not exist in 8.4, so that part stops at 9.0.

Noah Misch and Heikki Linnakangas, reviewed by Tom Lane.

Security: CVE-2014-0064

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/12bbce15d93d7692ddff1405aa04b67f8a327f57

Modified Files
--------------
contrib/hstore/hstore.h | 15 ++++++++++++---
contrib/hstore/hstore_io.c | 21 +++++++++++++++++++++
contrib/hstore/hstore_op.c | 15 +++++++++++++++
contrib/intarray/_int.h | 2 ++
contrib/intarray/_int_bool.c | 9 +++++++++
contrib/ltree/ltree.h | 3 +++
contrib/ltree/ltree_io.c | 11 +++++++++++
contrib/ltree/ltxtquery_io.c | 13 ++++++++++++-
src/backend/utils/adt/geo_ops.c | 30 ++++++++++++++++++++++++++++--
src/backend/utils/adt/tsquery.c | 7 ++++++-
src/backend/utils/adt/tsquery_util.c | 5 +++++
src/backend/utils/adt/txid.c | 15 +++++----------
src/backend/utils/adt/varbit.c | 32 ++++++++++++++++++++++++++++++--
src/include/tsearch/ts_type.h | 3 +++
src/include/utils/varbit.h | 7 +++++++
15 files changed, 169 insertions(+), 19 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2014-02-17 15:05:47 pgsql: Document security implications of check_function_bodies.
Previous Message Noah Misch 2014-02-17 15:05:45 pgsql: Shore up ADMIN OPTION restrictions.