[postgis-devel] [PostGIS] #1179: st_astext crash with bad value

PostGIS trac at osgeo.org
Mon Sep 5 11:04:08 PDT 2011

#1179: st_astext crash with bad value
 Reporter:  kjurka   |       Owner:  pramsey      
     Type:  defect   |      Status:  new          
 Priority:  high     |   Milestone:  PostGIS 1.5.4
Component:  postgis  |     Version:  1.5.X        
 Keywords:           |  
 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

 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.

Ticket URL: <https://trac.osgeo.org/postgis/ticket/1179>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.

More information about the postgis-devel mailing list