server crash in to_timestamp function - Mailing list pgsql-hackers

From Ibrar Ahmed
Subject server crash in to_timestamp function
Date
Msg-id 8494ccf60811110430p231714e1j54dacfd4cd7c1222@mail.gmail.com
Whole thread Raw
Responses Re: server crash in to_timestamp function  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

While looking at the code base I have encountered a server crash in
to_timestamp function.

select TO_TIMESTAMP ( '2006 1', 'YYYY Q' );
server closed the connection unexpectedly       This probably means the server terminated abnormally       before or
whileprocessing the request.
 
The connection to the server was lost. Attempting reset: Failed.

I further debugged the issue and here are my thoughts


[function DCH_from_char]
                       ...
        case DCH_Q:            /*             * We ignore Q when converting to date because it is not             *
normative.            *             * We still parse the source string for an integer, but it             * isn't
storedanywhere in 'out'.             */            from_char_parse_int((int *) NULL, &s, n);            s +=
SKIP_THth(n->suffix);                              ...
 


This piece of code is calling function "from_char_parse_int"  with
first argument NULL. The function "from_char_parse_int" in turn calls
"from_char_parse_int_len" which in turn calls "from_char_set_int".
In the function "from_char_set_int" the first argument "dest" is being
derefernced without the null check.
(if (*dest != 0 && *dest != value)

--   Ibrar Ahmed  EnterpriseDB   http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Zdenek Kotala
Date:
Subject: Re: pg_upgrade project status
Next
From: Magnus Hagander
Date:
Subject: Duplicated docs on libpq parameters