pgsql: Be more paranoid in ruleutils.c's get_variable().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Be more paranoid in ruleutils.c's get_variable().
Date: 2016-07-01 15:40:49
Message-ID: E1bJ0Yj-0002z8-7U@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Be more paranoid in ruleutils.c's get_variable().

We were merely Assert'ing that the Var matched the RTE it's supposedly
from. But if the user passes incorrect information to pg_get_expr(),
the RTE might in fact not match; this led either to Assert failures
or core dumps, as reported by Chris Hanks in bug #14220. To fix, just
convert the Asserts to test-and-elog. Adjust an existing test-and-elog
elsewhere in the same function to be consistent in wording.

(If we really felt these were user-facing errors, we might promote them to
ereport's; but I can't convince myself that they're worth translating.)

Back-patch to 9.3; the problematic code doesn't exist before that, and
a quick check says that 9.2 doesn't crash on such cases.

Michael Paquier and Thomas Munro

Report: <20160629224349(dot)1407(dot)32667(at)wrigleys(dot)postgresql(dot)org>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/0daeba0e927bfcb3d0ed9d510b84e555fc1e2741

Modified Files
--------------
src/backend/utils/adt/ruleutils.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2016-07-01 15:53:23 pgsql: Set consider_parallel correctly for upper planner rels.
Previous Message Robert Haas 2016-07-01 15:38:03 Re: pgsql: Fix crash bug in RestoreSnapshot.