[postgis-tickets] [PostGIS] #4173: Undefined behaviour in ptarray_segmentize2d

PostGIS trac at osgeo.org
Fri Sep 7 03:11:21 PDT 2018


#4173: Undefined behaviour in ptarray_segmentize2d
------------------------+---------------------------
 Reporter:  Algunenano  |      Owner:  pramsey
     Type:  defect      |     Status:  new
 Priority:  medium      |  Milestone:  PostGIS 2.5.0
Component:  postgis     |    Version:  trunk
 Keywords:              |
------------------------+---------------------------
 It comes from test `test_lwgeom_segmentize2d`:
 {{{
         linein = lwgeom_from_wkt("LINESTRING(0 0,10 0)",
 LW_PARSER_CHECK_NONE);
         lwgeom_request_interrupt();
         lineout = lwgeom_segmentize2d(linein, 1e-100);
         CU_ASSERT_EQUAL(lineout, NULL);
         lwgeom_free(linein);
 }}}

 {{{
 $ ./cunit/.libs/lt-cu_tester test_lwgeom_segmentize2d

 Running test 'test_lwgeom_segmentize2d' in suite 'measures'.
 ptarray.c:450:10: runtime error: 1e+101 is outside the range of
 representable values of type 'unsigned int'
 }}}

 I'll need to check if it affects both 3.0 and 2.5.


 I feel that the code is probably filled with these kind of issues (unsafe
 casting from double to integer types), but since those are corner cases
 I'll  limit myself to fix whatever comes up when running unit tests.

 WIP in https://github.com/postgis/postgis/pull/292

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4173>
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-tickets mailing list