Re: PG crash on simple query, story continues

From: "Maksim Likharev" <mlikharev(at)aurigin(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-general(at)postgresql(dot)org>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PG crash on simple query, story continues
Date: 2003-07-08 18:57:18
Message-ID: 56510AAEF435D240958D1CE8C6B1770A014A0DDD@mailc03.aurigin.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

>> !if error happend, xfrmlen will be (size_t)-1
>No it won't; see the man page for strxfrm.

RETURN VALUES
Upon successful completion, strxfrm() returns the length of
the transformed string (not including the terminating null
byte). If the value returned is n or more, the contents of
the array pointed to by s1 are indeterminate.

On failure, strxfrm() returns (size_t)-1.

but you a right it is strxfrm() that returns more than allowed,
most likely in following condition:
strxfrm(xfrmstr, val, 0)

a null terminator extra.

I am on SunOS 5.8,
BTW on Linux it works....

-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Tuesday, July 08, 2003 11:45 AM
To: Maksim Likharev
Cc: pgsql-general(at)postgresql(dot)org; pgsql-hackers(at)postgresql(dot)org
Subject: Re: [GENERAL] PG crash on simple query, story continues

"Maksim Likharev" <mlikharev(at)aurigin(dot)com> writes:
> ! I would say very interesting aproach,
> ! why not just
> xfrmsize = strxfrm(xfrmstr, NULL, 0);

strxfrm doesn't work that way (and if it did, it would give back a
malloc'd not a palloc'd string).

> !if error happend, xfrmlen will be (size_t)-1

No it won't; see the man page for strxfrm.

This does raise an interesting thought though: what platform are you on?
It seems to me that we've heard of buggy versions of strxfrm that write
more bytes than they're allowed to, thereby clobbering palloc's data
structures.

regards, tom lane

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2003-07-08 19:01:10 Re: SQL Functions and plan time
Previous Message Tom Lane 2003-07-08 18:48:11 Re: SQL Functions and plan time

Browse pgsql-hackers by date

  From Date Subject
Next Message Kurt Roeckx 2003-07-08 20:25:44 Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:
Previous Message Tom Lane 2003-07-08 18:44:53 Re: PG crash on simple query, story continues