]> granicus.if.org Git - postgis/commitdiff
Fix buffer overflow in lwgeom_to_geojson (#2052)
authorSandro Santilli <strk@keybit.net>
Wed, 17 Oct 2012 09:45:36 +0000 (09:45 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 17 Oct 2012 09:45:36 +0000 (09:45 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10448 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/cu_out_geojson.c
liblwgeom/lwout_geojson.c

index 325ffda2abf835aa4fb4b0f218a65d0d59951257..a3141a0cac33682ae289e1a64414986567ce53b3 100644 (file)
@@ -81,6 +81,13 @@ static void out_geojson_test_precision(void)
            "POINT(1E300 -1E300)",
            "{\"type\":\"Point\",\"coordinates\":[1e+300,-1e+300]}",
            NULL, 0, 0);
+
+       /* huge precision, see http://trac.osgeo.org/postgis/ticket/2052 */
+       do_geojson_test(
+           "POINT(1 2)",
+           "{\"type\":\"Point\",\"coordinates\":[1,2]}",
+           NULL, 100, 0);
+
 }
 
 
index 1c69717b2fc6d983bf73eb065938221d7bf0eda5..60d2c2e7ab22c7af62ece8ec7bfe1d5fbfb556fa 100644 (file)
@@ -38,6 +38,8 @@ lwgeom_to_geojson(const LWGEOM *geom, char *srs, int precision, int has_bbox)
        GBOX tmp;
        int rv;
 
+       if ( precision > OUT_MAX_DIGS_DOUBLE ) precision = OUT_MAX_DIGS_DOUBLE;
+
        if (has_bbox) 
        {
                /* Whether these are geography or geometry,