Re: Error check always bypassed in tablefunc.c

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Error check always bypassed in tablefunc.c
Date: 2015-01-26 06:32:51
Message-ID: CAB7nPqQYFp4T7LwSBhOfO2SgH5ysATHwqubzJWmvUDb6zbdGNw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Jan 17, 2015 at 11:16 PM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
> Patch is attached. Comments welcome.
So, I have been poking at this code a bit more and as the values of
the parameters are passed as-is to the SQL queries that connectby
generates internally (this is as well mentioned in the documentation
here: http://www.postgresql.org/docs/devel/static/tablefunc.html), you
can do quite fancy things by passing for example values of the type
"foo FROM table; --" or similar. Particularly, by enforcing a query
returning only one column, or NULL values I am even able to crash the
server. The interesting part is that even if compatConnectbyTupleDescs
is enabled for each level, it is still possible to crash the server by
passing for example NULL values casted to the same type, like that
'NULL::text, NULL::text; --'.
The attached patch fixes all those things, I have also enabled
compatConnectbyTupleDescs to run at each level. I'll add it to the
next CF as well to not lose track of it. This behavior has been like
that forever...
--
Michael

Attachment Content-Type Size
0001-Fix-crashes-and-tuple-compatibility-checks-in-connec.patch text/x-patch 11.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2015-01-26 07:13:34 Re: Client deadlocks when connecting via ssl
Previous Message Amit Langote 2015-01-26 01:42:57 Re: Partitioning: issues/ideas (Was: Re: On partitioning)