]> granicus.if.org Git - postgresql/commit
Avoid possibly accessing off the end of memory in examine_attribute().
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 6 Sep 2011 18:35:46 +0000 (14:35 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 6 Sep 2011 18:37:59 +0000 (14:37 -0400)
commit305c5ed6d7fbadac07a100939c4545bd21416552
tree2b53835251eac4d1e745a22b6b745be236062a01
parentb7e13b92796c1a2c3734d9e7d0a8d44bb8ca4fa5
Avoid possibly accessing off the end of memory in examine_attribute().

Since the last couple of columns of pg_type are often NULL,
sizeof(FormData_pg_type) can be an overestimate of the actual size of the
tuple data part.  Therefore memcpy'ing that much out of the catalog cache,
as analyze.c was doing, poses a small risk of copying past the end of
memory and incurring SIGSEGV.  No such crash has been identified in the
field, but we've certainly seen the equivalent happen in other code paths,
so patch this one all the way back.

Per valgrind testing by Noah Misch, though this is not his proposed patch.
I chose to use SearchSysCacheCopy1 rather than inventing special-purpose
infrastructure for copying only the minimal part of a pg_type tuple.
src/backend/commands/analyze.c