Re: SQLDA fix for ECPG

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>, Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: SQLDA fix for ECPG
Date: 2011-11-19 21:56:03
Message-ID: 4EC825F3.5080504@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

2011-11-17 14:53 keltezéssel, Michael Meskes írta:
> On Mon, Nov 14, 2011 at 09:06:30AM +0100, Boszormenyi Zoltan wrote:
>> Yes, you are right. For timestamp and interval, the safe alignment is int64.
>> Patch is attached.
> Applied, thanks.
>
> Michael

thanks.

Hopefully last turn in this topic. For NUMERIC types, the safe minimum
alignment is a pointer because there are 5 int members followed by
two pointer members in this struct. I got a crash from this with a lucky
query and dataset. The DECIMAL struct is safe because the digits[] array
is embedded there.

After fixing this, I got another one at an innocent looking memcpy():

memcpy((char *) sqlda + offset, num->buf, num->ndigits + 1);

It turned out that when the server sends "0.00", PGTYPESnumeric_from_asc()
constructs a numeric structure with:
ndigits == 0
buf == NULL
digits == NULL.
This makes memcpy() crash and burn. Let's also fix this case.

Best regards,
Zoltán Böszörményi

--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
http://www.postgresql.at/

Attachment Content-Type Size
ecpg-sqlda-part3.patch text/plain 3.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Florian Pflug 2011-11-20 00:41:31 Re: range_adjacent and discrete ranges
Previous Message Tom Lane 2011-11-19 21:03:01 Re: range_adjacent and discrete ranges