Opened 8 years ago

Closed 8 years ago

#1179 closed defect (fixed)

st_astext crash with bad value

Reported by: kjurka Owned by: pramsey
Priority: high Milestone: PostGIS 1.5.4
Component: postgis Version: 1.5.X
Keywords: Cc:

Description

When copying and pasting a value to put into st_astext, I accidentally got a newline character in there and it resulted in a server crash. It crashed trying to put together the error message because the error location was not set properly.

This is with postgis 1.5 SVN running against 9.1rc1 server on x86_64 linux.

Here's the test case: SELECT st_astext('0101000020AD100000C85D698D889A5D\nC09EF3C3134FF54040');

Attached is a patch which does a couple of things:

1) Initializes the error location to zero so we don't crash if it doesn't get set later on.

2) Changes the LWGEOM_WKB_PARSER_ERROR macro to assign the error location.

3) Changes the current position location calculation in strhex_readbyte to correctly track it. We're reading two characters at a time here, not one.

Attachments (2)

parse-failure.patch (1.1 KB) - added by kjurka 8 years ago.
stacktrace.txt (4.8 KB) - added by kjurka 8 years ago.

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by kjurka

Attachment: parse-failure.patch added

Changed 8 years ago by kjurka

Attachment: stacktrace.txt added

comment:1 Changed 8 years ago by pramsey

Resolution: fixed
Status: newclosed

Confirmed, doesn't crash for me on OSX, but does give me a bogus error location, so I can see how others might get worse failures. I've applied this to 1.5 branch.

Note: See TracTickets for help on using tickets.