[SCM] PostGIS branch master updated. 3.5.0-113-ga92d63e5c

git at osgeo.org git at osgeo.org
Fri Dec 13 13:21:26 PST 2024


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  a92d63e5cd4bcff2fa7f41f801be2fec1ab3ccc8 (commit)
      from  49df3d0a67792437db017f54f95e32050d93fcfb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a92d63e5cd4bcff2fa7f41f801be2fec1ab3ccc8
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Dec 13 13:21:13 2024 -0800

    Handle null returns from wkb parser

diff --git a/postgis/geography_inout.c b/postgis/geography_inout.c
index a2ff6a280..ad809d9bd 100644
--- a/postgis/geography_inout.c
+++ b/postgis/geography_inout.c
@@ -563,6 +563,11 @@ Datum geography_recv(PG_FUNCTION_ARGS)
 	}
 
 	lwgeom = lwgeom_from_wkb((uint8_t*)buf->data, buf->len, LW_PARSER_CHECK_ALL);
+	if ( !lwgeom )
+	{
+		ereport(ERROR,(errmsg("recv error - invalid geometry")));
+		PG_RETURN_NULL();
+	}
 
 	/* Error on any SRID != default */
 	srid_check_latlong(lwgeom->srid);
diff --git a/postgis/lwgeom_inout.c b/postgis/lwgeom_inout.c
index f936bb211..7127e326d 100644
--- a/postgis/lwgeom_inout.c
+++ b/postgis/lwgeom_inout.c
@@ -133,6 +133,8 @@ Datum LWGEOM_in(PG_FUNCTION_ARGS)
 		unsigned char *wkb = bytes_from_hexbytes(str, hexsize);
 		/* TODO: 20101206: No parser checks! This is inline with current 1.5 behavior, but needs discussion */
 		lwgeom = lwgeom_from_wkb(wkb, hexsize/2, LW_PARSER_CHECK_NONE);
+		/* Parser should throw error, but if not, catch here. */
+		if ( !lwgeom ) PG_RETURN_NULL();
 		/* If we picked up an SRID at the head of the WKB set it manually */
 		if ( srid ) lwgeom_set_srid(lwgeom, srid);
 		/* Add a bbox if necessary */
@@ -698,6 +700,11 @@ Datum LWGEOM_recv(PG_FUNCTION_ARGS)
 	}
 
 	lwgeom = lwgeom_from_wkb((uint8_t*)buf->data, buf->len, LW_PARSER_CHECK_ALL);
+	if ( !lwgeom )
+	{
+		ereport(ERROR,(errmsg("recv error - invalid geometry")));
+		PG_RETURN_NULL();
+	}
 
 	if ( lwgeom_needs_bbox(lwgeom) )
 		lwgeom_add_bbox(lwgeom);
diff --git a/raster/rt_core/rt_gdal.c b/raster/rt_core/rt_gdal.c
index 95038b256..90a509a99 100644
--- a/raster/rt_core/rt_gdal.c
+++ b/raster/rt_core/rt_gdal.c
@@ -284,6 +284,7 @@ int rt_raster_gdal_contour(
 		/* Reclaim feature and associated geometry memory */
 		OGR_F_Destroy(hFeat);
 		geom = lwgeom_from_wkb(bufWkb, szWkb, LW_PARSER_CHECK_NONE);
+		if (!geom) rterror("%s: invalid wkb", __func__);
 		lwgeom_set_srid(geom, arg.dst.srid);
 		contour.geom = gserialized_from_lwgeom(geom, NULL);
 		lwgeom_free(geom);
diff --git a/raster/rt_core/rt_geometry.c b/raster/rt_core/rt_geometry.c
index 3bc79bf9e..7c997d44f 100644
--- a/raster/rt_core/rt_geometry.c
+++ b/raster/rt_core/rt_geometry.c
@@ -1232,6 +1232,7 @@ rt_raster_gdal_polygonize(
 
 		/* convert WKB to LWGEOM */
 		lwgeom = lwgeom_from_wkb(wkb, wkbsize, LW_PARSER_CHECK_NONE);
+		if (!lwgeom) rterror("%s: invalid wkb", __func__);
 
 #if POSTGIS_DEBUG_LEVEL > 3
 		{

-----------------------------------------------------------------------

Summary of changes:
 postgis/geography_inout.c    | 5 +++++
 postgis/lwgeom_inout.c       | 7 +++++++
 raster/rt_core/rt_gdal.c     | 1 +
 raster/rt_core/rt_geometry.c | 1 +
 4 files changed, 14 insertions(+)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list