]> granicus.if.org Git - postgresql/commit
Fix PQsetvalue() to avoid possible crash when adding a new tuple.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 21 Jul 2011 16:24:14 +0000 (12:24 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 21 Jul 2011 16:25:01 +0000 (12:25 -0400)
commitfe0e1a633a164cfc0cddae0ee318d40230a491b0
treeaa5ccc1bbe87287b80afb53953bfe1ab6f27d4f2
parent431b7b84fe0fb830499561a31021932550817a8e
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
src/interfaces/libpq/fe-exec.c