[SCM] PostGIS branch stable-3.0 updated. 3.0.11-6-gd01fd3e2b

git at osgeo.org git at osgeo.org
Fri Dec 13 13:28:32 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, stable-3.0 has been updated
       via  d01fd3e2bee03afc6c0c87499fb7ad1662e9b64a (commit)
      from  3096143c4497e839c9e0c394ad78597c8d49843e (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 d01fd3e2bee03afc6c0c87499fb7ad1662e9b64a
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 89ad0ebe3..4c8dac0ac 100644
--- a/postgis/geography_inout.c
+++ b/postgis/geography_inout.c
@@ -615,6 +615,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(fcinfo, lwgeom->srid);
diff --git a/postgis/lwgeom_inout.c b/postgis/lwgeom_inout.c
index c3470699d..d48f53e9e 100644
--- a/postgis/lwgeom_inout.c
+++ b/postgis/lwgeom_inout.c
@@ -132,6 +132,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 */
@@ -765,6 +767,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_geometry.c b/raster/rt_core/rt_geometry.c
index 3a2f92038..7d9ff485b 100644
--- a/raster/rt_core/rt_geometry.c
+++ b/raster/rt_core/rt_geometry.c
@@ -1202,6 +1202,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_geometry.c | 1 +
 3 files changed, 13 insertions(+)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list