[postgis-tickets] [SCM] PostGIS branch stable-3.1 updated. 3.1.5-3-gf1e799c7e

git at osgeo.org git at osgeo.org
Fri Feb 25 07:09:17 PST 2022


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.1 has been updated
       via  f1e799c7ee4a76f0d1029f91983f9dd2e05db8fe (commit)
      from  1a90fe80e3887248d506ae2cabf9c9d84953213d (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 f1e799c7ee4a76f0d1029f91983f9dd2e05db8fe
Author: Laurenz Albe <laurenz.albe at cybertec.at>
Date:   Thu Feb 24 23:13:56 2022 -0500

    Stop using pg_atoi, removed in PG 15
    Closes #5100 for PostGIS 3.1.6

diff --git a/NEWS b/NEWS
index c8bccc0f8..c0f0071b7 100644
--- a/NEWS
+++ b/NEWS
@@ -3,7 +3,7 @@ PostGIS 3.1.6
 
 * Bug Fixes
   - #5076, Avoid log storm installed with pgaudit enabled (Paul Ramsey)
-
+  - #5100, Stop using pg_atoi, removed in PG 15 (Laurenz Albe)
 
 PostGIS 3.1.5
 2022/02/01
diff --git a/postgis/geography_inout.c b/postgis/geography_inout.c
index 7dae289bc..4e62e0b10 100644
--- a/postgis/geography_inout.c
+++ b/postgis/geography_inout.c
@@ -34,7 +34,7 @@
 
 #include "utils/elog.h"
 #include "utils/array.h"
-#include "utils/builtins.h"  /* for pg_atoi */
+#include "utils/builtins.h"  /* for text_to_cstring */
 #include "lib/stringinfo.h"  /* For binary input */
 #include "catalog/pg_type.h" /* for CSTRINGOID, INT4OID */
 
diff --git a/postgis/gserialized_typmod.c b/postgis/gserialized_typmod.c
index 9d8119084..aae44bef5 100644
--- a/postgis/gserialized_typmod.c
+++ b/postgis/gserialized_typmod.c
@@ -31,10 +31,11 @@
 #include <float.h>
 #include <string.h>
 #include <stdio.h>
+#include <errno.h>
 
 #include "utils/elog.h"
 #include "utils/array.h"
-#include "utils/builtins.h"  /* for pg_atoi */
+#include "utils/builtins.h"  /* for cstring_to_text */
 #include "lib/stringinfo.h"  /* For binary input */
 #include "catalog/pg_type.h" /* for CSTRINGOID */
 
@@ -272,8 +273,33 @@ static uint32 gserialized_typmod_in(ArrayType *arr, int is_geography)
 		}
 		if ( i == 1 ) /* SRID */
 		{
-			int32_t srid = pg_atoi(DatumGetCString(elem_values[i]), sizeof(int32), '\0');
-			srid = clamp_srid(srid);
+			char *int_string = DatumGetCString(elem_values[i]);
+			char *endp;
+			long l;
+			int32_t srid;
+
+			errno = 0;
+			l = strtol(int_string, &endp, 10);
+
+			if (int_string == endp)
+				ereport(ERROR,
+						(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+						 errmsg("invalid input syntax for type %s: \"%s\"",
+								"integer", int_string)));
+
+			if (errno == ERANGE || l < INT_MIN || l > INT_MAX)
+				ereport(ERROR,
+						(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
+						 errmsg("value \"%s\" is out of range for type %s", int_string,
+								"integer")));
+
+			if (*endp != '\0')
+				ereport(ERROR,
+						(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+						 errmsg("invalid input syntax for type %s: \"%s\"",
+								"integer", int_string)));
+
+			srid = clamp_srid(l);
 			POSTGIS_DEBUGF(3, "srid: %d", srid);
 			if ( srid != SRID_UNKNOWN )
 			{
diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c
index b44bfb204..964321dd5 100644
--- a/postgis/lwgeom_geos.c
+++ b/postgis/lwgeom_geos.c
@@ -3032,8 +3032,8 @@ Datum clusterintersecting_garray(PG_FUNCTION_ARGS)
 	char elmalign;
 
 	/* Null array, null geometry (should be empty?) */
-    if (PG_ARGISNULL(0))
-        PG_RETURN_NULL();
+	if (PG_ARGISNULL(0))
+		PG_RETURN_NULL();
 
 	array = PG_GETARG_ARRAYTYPE_P(0);
     nelems = array_nelems_not_null(array);

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

Summary of changes:
 NEWS                         |  2 +-
 postgis/geography_inout.c    |  2 +-
 postgis/gserialized_typmod.c | 32 +++++++++++++++++++++++++++++---
 postgis/lwgeom_geos.c        |  4 ++--
 4 files changed, 33 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list