From 10477191b0a118a1c1ee57dc2f9eba996d3211d0 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Wed, 9 Jan 2019 16:42:23 +0000 Subject: [PATCH] Tighten up parsing to account for strings with junk after valid geometry References #4273 git-svn-id: http://svn.osgeo.org/postgis/trunk@17127 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis/lwgeom_inout.c | 3 ++- postgis/lwgeom_ogc.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/postgis/lwgeom_inout.c b/postgis/lwgeom_inout.c index d822fc802..8588d46f2 100644 --- a/postgis/lwgeom_inout.c +++ b/postgis/lwgeom_inout.c @@ -143,7 +143,8 @@ Datum LWGEOM_in(PG_FUNCTION_ARGS) /* WKT then. */ else { - if ( lwgeom_parse_wkt(&lwg_parser_result, str, LW_PARSER_CHECK_ALL) == LW_FAILURE ) + int rv = lwgeom_parse_wkt(&lwg_parser_result, str, LW_PARSER_CHECK_ALL); + if ( rv == LW_FAILURE || lwg_parser_result.errcode ) { PG_PARSER_ERROR(lwg_parser_result); PG_RETURN_NULL(); diff --git a/postgis/lwgeom_ogc.c b/postgis/lwgeom_ogc.c index 71c24b466..b5168ebb4 100644 --- a/postgis/lwgeom_ogc.c +++ b/postgis/lwgeom_ogc.c @@ -788,11 +788,13 @@ Datum LWGEOM_from_text(PG_FUNCTION_ARGS) LWGEOM_PARSER_RESULT lwg_parser_result; GSERIALIZED *geom_result = NULL; LWGEOM *lwgeom; + int rv; POSTGIS_DEBUG(2, "LWGEOM_from_text"); POSTGIS_DEBUGF(3, "wkt: [%s]", wkt); - if (lwgeom_parse_wkt(&lwg_parser_result, wkt, LW_PARSER_CHECK_ALL) == LW_FAILURE) + rv = lwgeom_parse_wkt(&lwg_parser_result, wkt, LW_PARSER_CHECK_ALL); + if (rv == LW_FAILURE || lwg_parser_result.errcode) PG_PARSER_ERROR(lwg_parser_result); lwgeom = lwg_parser_result.geom; -- 2.40.0