Re: invalid memory alloc request size with extension url_decode

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tobias Florek <postgres(at)ibotty(dot)net>
Cc: PGSQL-Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: invalid memory alloc request size with extension url_decode
Date: 2014-08-28 14:35:13
Message-ID: 25644.1409236513@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Tobias Florek <postgres(at)ibotty(dot)net> writes:
> for my untrained eye, the code [2] looks reasonable. it does use the
> following idiom though.

> len = VARSIZE(in_text) - VARHDRSZ;

This would be okay except that the in_text value was extracted with
PG_GETARG_TEXT_PP rather than PG_GETARG_TEXT_P. That allows the
value to be a short-header Datum, which this code is not prepared for.

You could either change the wrapper functions to use PG_GETARG_TEXT_P,
or fix the subroutines to use VARDATA_ANY and VARSIZE_ANY_EXHDR
when inspecting their text* arguments.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Keith 2014-08-28 14:46:52 Re: PG 9.1 much slower than 8.2 ?
Previous Message Tobias Florek 2014-08-28 14:29:17 Re: invalid memory alloc request size with extension url_decode