pgsql: Fix PQsetvalue() to avoid possible crash when adding a new tuple

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix PQsetvalue() to avoid possible crash when adding a new tuple
Date: 2011-07-21 16:25:48
Message-ID: E1Qjw4K-0000BV-3f@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix PQsetvalue() to avoid possible crash when adding a new tuple.

PQsetvalue unnecessarily duplicated the logic in pqAddTuple, and didn't
duplicate it exactly either --- pqAddTuple does not care what is in the
tuple-pointer array positions beyond the last valid entry, whereas the
code in PQsetvalue assumed such positions would contain NULL. This led
to possible crashes if PQsetvalue was applied to a PGresult that had
previously been enlarged with pqAddTuple, for instance one built from a
server query. Fix by relying on pqAddTuple instead of duplicating logic,
and not assuming anything about the contents of res->tuples[res->ntups].

Back-patch to 8.4, where PQsetvalue was introduced.

Andrew Chernow

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/64207122a241282189451fdcbab3f5e2a6e1e1b1

Modified Files
--------------
src/interfaces/libpq/fe-exec.c | 27 ++++-----------------------
1 files changed, 4 insertions(+), 23 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2011-07-21 16:56:53 Re: Re: [COMMITTERS] pgsql: Remove O(N^2) performance issue with multiple SAVEPOINTs.
Previous Message Tom Lane 2011-07-21 15:33:10 pgsql: Make xpath() do something useful with XPath expressions that ret