st_astext crash with bad value
|Reported by:||kjurka||Owned by:||pramsey|
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.