to_tsquery stack overflow

From: "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>
To: "PostgreSQL Bugs" <pgsql-bugs(at)postgresql(dot)org>
Subject: to_tsquery stack overflow
Date: 2007-08-30 10:02:24
Message-ID: 46D695B0.9020009@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Passing a query with enough nested parenthesis in it causes a segfault.
Attached is a handy little program to generate such a query, the actual
query was too big to get through to the list.

The problem seems to be unbounded recursion in the makepol function that
converts the input query from infix to polish notation. An easy fix
would be to just add a level parameter to makepol that's incremented on
each recursion, and throw an error if it grows bigger than some safe
limit. There might be a similar problem in TS_execute as well, if you
can somehow pass a complex enough TSQuery to the system, perhaps with a
custom libpq client and tsqueryrecv.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

Attachment Content-Type Size
bigtsquery.c text/x-csrc 337 bytes

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2007-08-30 11:14:20 Re: to_tsquery stack overflow
Previous Message Fuminori Ido 2007-08-30 10:01:54 Re: BUG #3589: /etc/init.d/postgresql reload doesn't reflect /etc/postgresql/postgresql.conf log_statement