Skip site navigation (1) Skip section navigation (2)

Re: empty array can crash backend using int_array_enum from contrib.

From: Andrew - Supernews <andrew+nonews(at)supernews(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: empty array can crash backend using int_array_enum from contrib.
Date: 2005-04-23 06:51:50
Message-ID: slrnd6js46.27a.andrew+nonews@trinity.supernews.net (view raw or flat)
Thread:
Lists: pgsql-bugs
On 2005-04-23, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com> writes:
>> Using the int_array_enum function from contrib/intagg I can crash the
>> 8.0.2 backend when I pass it an empty array.
>
> Man, we've had a few problems with that thing, haven't we?
>
> I patched it along these lines:
[snip]

We were discussing this one on irc while it was presumably waiting in the
moderation queue, and I suggested to the poster an alternative patch that
allowed empty arrays to actually be treated as empty (your version will
error out on int_array_enum('{}') rather than producing 0 rows, which seems
unhelpful). I would suggest changing your test from != 1 to > 1, and adding
the moral equivalent of:

--- int_aggregate.c.orig        Fri Apr 22 11:37:09 2005
+++ int_aggregate.c     Fri Apr 22 11:44:34 2005
@@ -227,7 +227,7 @@
        else    /* use an existing one */
                pc = (CTX *) fcinfo->context;
        /* Are we done yet? */
-       if (pc->num >= pc->p->items)
+       if (ARR_NDIM(pc->p) != 1 || pc->num >= pc->p->items)
        {
                /* We are done */
                if (pc->flags & TOASTED)

(that test could be moved into the setup phase, of course)

-- 
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services

In response to

Responses

pgsql-bugs by date

Next:From: Dennis VshivkovDate: 2005-04-23 15:27:14
Subject: Re: BUG #1618: EXTRACTing EPOCH from TIME WITH TIME ZONE is broken
Previous:From: Tom LaneDate: 2005-04-23 06:34:34
Subject: Re: V2 protocol -> 8.1 server

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group