[SCM] PostGIS branch stable-3.5 updated. 3.5.5-13-g5c1ed575d
git at osgeo.org
git at osgeo.org
Thu Apr 9 14:57:49 PDT 2026
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.5 has been updated
via 5c1ed575d82b33355f2ed338e5c41c30e99d2f48 (commit)
from e880eb8371ee31ada8b11c0fa580b08f1d4dc806 (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 5c1ed575d82b33355f2ed338e5c41c30e99d2f48
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Thu Apr 9 14:57:33 2026 -0700
WKT parser produces incorrect error locations.
In extreme cases causes occasional crashes.
References #6061
diff --git a/NEWS b/NEWS
index a75a2f7c6..23a96792c 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ PostgreSQL 12-18 required. GEOS 3.8+ required. Proj 6.1+ required.
- #6058, Use Pg composite_to_json() function in 19+ (Paul Ramsey)
- #6060, fully quality calls to helper functions (Paul Ramsey)
- #6026, KNN failure in rare IEEE double rounding case (Paul Ramsey)
+ - #6061, WKT parser produces incorrect error locations (Paul Ramsey)
PostGIS 3.5.5
diff --git a/liblwgeom/lwin_wkt_lex.c b/liblwgeom/lwin_wkt_lex.c
index f194112fa..d6b0845c2 100644
--- a/liblwgeom/lwin_wkt_lex.c
+++ b/liblwgeom/lwin_wkt_lex.c
@@ -1179,29 +1179,35 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
/* rule 1 can match eol */
+*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */
+YY_LINENO_REWIND_TO(yy_cp - 1);
+(yy_c_buf_p) = yy_cp -= 1;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
#line 62 "lwin_wkt_lex.l"
{
LWDEBUG(5,"DOUBLE");
wkt_yylval.doublevalue = atof(wkt_yytext);
- yyless(wkt_yyleng-1);
return DOUBLE_TOK;
}
YY_BREAK
case 2:
/* rule 2 can match eol */
+*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */
+YY_LINENO_REWIND_TO(yy_bp + 3);
+(yy_c_buf_p) = yy_cp = yy_bp + 3;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 69 "lwin_wkt_lex.l"
+#line 68 "lwin_wkt_lex.l"
{
LWDEBUG(5,"DOUBLE NAN");
wkt_yylval.doublevalue = NAN;
- yyless(wkt_yyleng-1);
return DOUBLE_TOK;
}
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 76 "lwin_wkt_lex.l"
+#line 74 "lwin_wkt_lex.l"
{
LWDEBUG(5,"SRID");
wkt_yylval.integervalue = wkt_lexer_read_srid(wkt_yytext);
@@ -1210,87 +1216,87 @@ YY_RULE_SETUP
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 82 "lwin_wkt_lex.l"
+#line 80 "lwin_wkt_lex.l"
{ return COLLECTION_TOK; }
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 83 "lwin_wkt_lex.l"
+#line 81 "lwin_wkt_lex.l"
{ return MSURFACE_TOK; }
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 84 "lwin_wkt_lex.l"
+#line 82 "lwin_wkt_lex.l"
{ return MPOLYGON_TOK; }
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 85 "lwin_wkt_lex.l"
+#line 83 "lwin_wkt_lex.l"
{ return MCURVE_TOK; }
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 86 "lwin_wkt_lex.l"
+#line 84 "lwin_wkt_lex.l"
{ return MLINESTRING_TOK; }
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 87 "lwin_wkt_lex.l"
+#line 85 "lwin_wkt_lex.l"
{ return MPOINT_TOK; }
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 88 "lwin_wkt_lex.l"
+#line 86 "lwin_wkt_lex.l"
{ return CURVEPOLYGON_TOK; }
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 89 "lwin_wkt_lex.l"
+#line 87 "lwin_wkt_lex.l"
{ return POLYGON_TOK; }
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 90 "lwin_wkt_lex.l"
+#line 88 "lwin_wkt_lex.l"
{ return COMPOUNDCURVE_TOK; }
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 91 "lwin_wkt_lex.l"
+#line 89 "lwin_wkt_lex.l"
{ return CIRCULARSTRING_TOK; }
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 92 "lwin_wkt_lex.l"
+#line 90 "lwin_wkt_lex.l"
{ return LINESTRING_TOK; }
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 93 "lwin_wkt_lex.l"
+#line 91 "lwin_wkt_lex.l"
{ return POLYHEDRALSURFACE_TOK; }
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 94 "lwin_wkt_lex.l"
+#line 92 "lwin_wkt_lex.l"
{ return TRIANGLE_TOK; }
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 95 "lwin_wkt_lex.l"
+#line 93 "lwin_wkt_lex.l"
{ return TIN_TOK; }
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 96 "lwin_wkt_lex.l"
+#line 94 "lwin_wkt_lex.l"
{ return POINT_TOK; }
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 97 "lwin_wkt_lex.l"
+#line 95 "lwin_wkt_lex.l"
{ return EMPTY_TOK; }
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 99 "lwin_wkt_lex.l"
+#line 97 "lwin_wkt_lex.l"
{
LWDEBUG(5,"DIMENSIONALITY");
wkt_yylval.stringvalue = wkt_yytext;
@@ -1299,33 +1305,33 @@ YY_RULE_SETUP
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 105 "lwin_wkt_lex.l"
+#line 103 "lwin_wkt_lex.l"
{ LWDEBUG(5,"LBRACKET"); return LBRACKET_TOK; }
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 106 "lwin_wkt_lex.l"
+#line 104 "lwin_wkt_lex.l"
{ LWDEBUG(5,"RBRACKET"); return RBRACKET_TOK; }
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 107 "lwin_wkt_lex.l"
+#line 105 "lwin_wkt_lex.l"
{ LWDEBUG(5,"COMMA"); return COMMA_TOK; }
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 108 "lwin_wkt_lex.l"
+#line 106 "lwin_wkt_lex.l"
{ LWDEBUG(5,"SEMICOLON"); return SEMICOLON_TOK; }
YY_BREAK
case 25:
/* rule 25 can match eol */
YY_RULE_SETUP
-#line 110 "lwin_wkt_lex.l"
+#line 108 "lwin_wkt_lex.l"
{ /* ignore whitespace */ LWDEBUG(5,"WHITESPACE"); }
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 112 "lwin_wkt_lex.l"
+#line 110 "lwin_wkt_lex.l"
{ /* Error out and stop parsing on unknown/unexpected characters */
LWDEBUG(5,"UNKNOWN");
wkt_lexer_unknown();
@@ -1334,10 +1340,10 @@ YY_RULE_SETUP
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 118 "lwin_wkt_lex.l"
+#line 116 "lwin_wkt_lex.l"
ECHO;
YY_BREAK
-#line 1340 "lwin_wkt_lex.c"
+#line 1346 "lwin_wkt_lex.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@@ -2283,7 +2289,7 @@ static int yy_flex_strlen (const char * s )
#define YYTABLES_NAME "yytables"
-#line 118 "lwin_wkt_lex.l"
+#line 116 "lwin_wkt_lex.l"
void *wkt_yyalloc (yy_size_t size )
diff --git a/liblwgeom/lwin_wkt_lex.l b/liblwgeom/lwin_wkt_lex.l
index d301a2259..f2a4d963c 100644
--- a/liblwgeom/lwin_wkt_lex.l
+++ b/liblwgeom/lwin_wkt_lex.l
@@ -59,17 +59,15 @@ static void wkt_lexer_unknown()
%%
--?(([0-9]+\.?)|([0-9]*\.?[0-9]+)([eE][-+]?[0-9]+)?)[ \,\)\t\n\r] {
+-?(([0-9]+\.?)|([0-9]*\.?[0-9]+)([eE][-+]?[0-9]+)?)/[ \,\)\t\n\r] {
LWDEBUG(5,"DOUBLE");
wkt_yylval.doublevalue = atof(wkt_yytext);
- yyless(wkt_yyleng-1);
return DOUBLE_TOK;
}
-([Nn][Aa][Nn])[ \,\)\t\n\r] {
+([Nn][Aa][Nn])/[ \,\)\t\n\r] {
LWDEBUG(5,"DOUBLE NAN");
wkt_yylval.doublevalue = NAN;
- yyless(wkt_yyleng-1);
return DOUBLE_TOK;
}
diff --git a/liblwgeom/lwutil.c b/liblwgeom/lwutil.c
index 3656af4e9..ad0dad519 100644
--- a/liblwgeom/lwutil.c
+++ b/liblwgeom/lwutil.c
@@ -276,6 +276,10 @@ char *lwmessage_truncate(char *str, int startpos, int endpos, int maxlength, int
char *output;
char *outstart;
+ int strsz = strlen(str);
+ if (endpos > strsz)
+ endpos = strsz;
+
/* Allocate space for new string */
output = lwalloc(maxlength + 4);
output[0] = '\0';
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
liblwgeom/lwin_wkt_lex.c | 66 ++++++++++++++++++++++++++----------------------
liblwgeom/lwin_wkt_lex.l | 6 ++---
liblwgeom/lwutil.c | 4 +++
4 files changed, 43 insertions(+), 34 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list