From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: Ronan Dunklau <ronan.dunklau@dalibo.com>
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Subject: Re: Server may segfault when using slices on int2vector
Date: Wed, 20 Nov 2013 13:43:48 +0200
Message-ID: <528CA074.4030307@vmware.com> (raw)
In-Reply-To: <2450353.1U6Qoyzd8o@ronan_laptop>
References: <2450353.1U6Qoyzd8o@ronan_laptop>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 19.11.2013 16:24, Ronan Dunklau wrote:
> Hello.
>
> While building a query on the pg_index relation, I came accross a bug which
> simplest form is manifested as this:
>
> select
> a.indkey[1:3],
> a.indkey[1:2]
> from pg_index as a
>
> This can result either in a segfault, a failed memory allocation or gibberish
> results.
Hmm. int2vectorout expects the int2vector to have a single dimension,
but array_get_slice() returns a zero-dimension array if the result is empty.
I don't think it's safe to allow slicing int2vectors (nor oidvectors).
It seems all too likely that the result violates the limitations of
int2vector. In addition to that segfault, the array returned is 1-based,
not 0-based as we assume for int2vectors. One consequence of that is
that if you COPY the value out in binary format and try to read it back,
you'll get an error.
So I think we should just not allow slicing oidvectors, and throw an
error. You can cast from int2vector to int2[], and slice and dice that
as much as you want, so it's not a big loss in functionality. Another
solution would to provide a specialized slice-function for int2vector
and oidvector, but it's probably not worth the effort.
Thanks for the report!
- Heikki
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: hlinnakangas@vmware.com, ronan.dunklau@dalibo.com
Subject: Re: Server may segfault when using slices on int2vector
In-Reply-To: <528CA074.4030307@vmware.com>
References: <2450353.1U6Qoyzd8o@ronan_laptop> <528CA074.4030307@vmware.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox