[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0alpha2-94-ga7851bb
git at osgeo.org
git at osgeo.org
Fri Oct 23 04:43:00 PDT 2020
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 a7851bb0659a86ed63f183fd8f536aa83942add7 (commit)
from e7ed833b6a7d00f15d338aa2de38b0050a64928d (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 a7851bb0659a86ed63f183fd8f536aa83942add7
Author: Raúl Marín <git at rmr.ninja>
Date: Sun Oct 18 00:01:33 2020 +0200
Fix segfault when parsing invalid WKB
References #4767 #4768 #4771 #4772
Closes https://github.com/postgis/postgis/pull/584
diff --git a/NEWS b/NEWS
index 49d9d96..9de0012 100644
--- a/NEWS
+++ b/NEWS
@@ -46,6 +46,7 @@ Only tickets not included in 3.1.0alpha2
- #4740, Round values in geography_distance_tree
as we do on geography_distance (Raúl Marín, Paul Ramsey, Regina Obe)
- #4739, Ensure all functions using postgis_oid initialize the internal cache (Raúl Marín)
+ - #4767, #4768, #4771, #4772, Fix segfault when parsing invalid WKB (Raúl Marín)
diff --git a/postgis/lwgeom_inout.c b/postgis/lwgeom_inout.c
index 8ce752d..e5e75af 100644
--- a/postgis/lwgeom_inout.c
+++ b/postgis/lwgeom_inout.c
@@ -349,6 +349,8 @@ Datum LWGEOMFromEWKB(PG_FUNCTION_ARGS)
uint8_t *wkb = (uint8_t*)VARDATA(bytea_wkb);
lwgeom = lwgeom_from_wkb(wkb, VARSIZE_ANY_EXHDR(bytea_wkb), LW_PARSER_CHECK_ALL);
+ if (!lwgeom)
+ lwpgerror("Unable to parse WKB");
if ((PG_NARGS() > 1) && (!PG_ARGISNULL(1)))
{
diff --git a/postgis/lwgeom_ogc.c b/postgis/lwgeom_ogc.c
index 6da4fe2..9d2f994 100644
--- a/postgis/lwgeom_ogc.c
+++ b/postgis/lwgeom_ogc.c
@@ -795,9 +795,8 @@ Datum LWGEOM_from_WKB(PG_FUNCTION_ARGS)
uint8_t *wkb = (uint8_t*)VARDATA(bytea_wkb);
lwgeom = lwgeom_from_wkb(wkb, VARSIZE_ANY_EXHDR(bytea_wkb), LW_PARSER_CHECK_ALL);
-
- if ( lwgeom_needs_bbox(lwgeom) )
- lwgeom_add_bbox(lwgeom);
+ if (!lwgeom)
+ lwpgerror("Unable to parse WKB");
geom = geometry_serialize(lwgeom);
lwgeom_free(lwgeom);
diff --git a/regress/core/wkb.sql b/regress/core/wkb.sql
index 9749db5..2fd59bf 100644
--- a/regress/core/wkb.sql
+++ b/regress/core/wkb.sql
@@ -533,3 +533,13 @@ select g, encode(st_asbinary(g::geometry, 'ndr'), 'hex'),
'TIN ZM EMPTY'
::text as g ) as foo;
+
+-- Crashes (#4767, #4768, #4771, #4772)
+SELECT st_mpointfromwkb('\x'::BYTEA);
+SELECT geometry('\x'::bytea);
+SELECT st_geomcollfromwkb('\x'::bytea);
+SELECT st_geomfromewkb('\x'::bytea);
+SELECT st_wkbtosql('\x');
+SELECT st_mpolyfromwkb('\x'::BYTEA);
+SELECT st_mlinefromwkb('\x'::bytea);
+SELECT st_mlinefromwkb('\x'::bytea,1);
\ No newline at end of file
diff --git a/regress/core/wkb_expected b/regress/core/wkb_expected
index 91fa0c8..090e646 100644
--- a/regress/core/wkb_expected
+++ b/regress/core/wkb_expected
@@ -99,3 +99,11 @@ TIN EMPTY|011000000000000000|t|000000001000000000
TIN Z EMPTY|01f803000000000000|t|00000003f800000000
TIN M EMPTY|01e007000000000000|t|00000007e000000000
TIN ZM EMPTY|01c80b000000000000|t|0000000bc800000000
+ERROR: Unable to parse WKB
+ERROR: Unable to parse WKB
+ERROR: Unable to parse WKB
+ERROR: Unable to parse WKB
+ERROR: Unable to parse WKB
+ERROR: Unable to parse WKB
+ERROR: Unable to parse WKB
+ERROR: Unable to parse WKB
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
postgis/lwgeom_inout.c | 2 ++
postgis/lwgeom_ogc.c | 5 ++---
regress/core/wkb.sql | 10 ++++++++++
regress/core/wkb_expected | 8 ++++++++
5 files changed, 23 insertions(+), 3 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list