[SCM] PostGIS branch stable-3.6 updated. 3.6.4-14-g6e3bc696c
git at osgeo.org
git at osgeo.org
Tue Jun 23 16:10:23 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.6 has been updated
via 6e3bc696c118daf13d54c37eaf1951b8b39a54f8 (commit)
via c42b9ea2f2cad8258f1abb6c599bc61ddf69fd1d (commit)
from 741f2aa59ec463cde5bb79e4dd15fb79c37196ee (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 6e3bc696c118daf13d54c37eaf1951b8b39a54f8
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Jun 23 16:09:33 2026 -0700
Avoid Inf loop in Geohash calculation
diff --git a/NEWS b/NEWS
index 2415100de..5687a7524 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ PostGIS 3.6.5
- #5357, ST_LineFromEncodedPolyline dropping close points (Paul Ramsey)
- OSSFuzz 525554772, avoid signed integer overflow (Even Rouault)
- OSSFuzz 525548201, avoid overly nested inputs (Darafei Praliaskouski)
+- Avoid Inf loop in Geohash calculation (Paul Ramsey)
PostGIS 3.6.4
commit c42b9ea2f2cad8258f1abb6c599bc61ddf69fd1d
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Jun 23 23:01:11 2026 +0000
Avoid Inf loop in Geohash calculation
diff --git a/liblwgeom/cunit/cu_algorithm.c b/liblwgeom/cunit/cu_algorithm.c
index 1194785c4..b70268984 100644
--- a/liblwgeom/cunit/cu_algorithm.c
+++ b/liblwgeom/cunit/cu_algorithm.c
@@ -3,7 +3,7 @@
* PostGIS - Spatial Types for PostgreSQL
* http://postgis.net
* Copyright 2008 Paul Ramsey
- * Copyright 2018 Darafei Praliaskouski, me at komzpa.net
+ * Copyright 2018, 2026 Darafei Praliaskouski <me at komzpa.net>
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU General Public Licence. See the COPYING file.
@@ -952,6 +952,15 @@ static void test_geohash_precision(void)
//printf("precision %d\n",precision);
CU_ASSERT_EQUAL(precision, 7);
+ /* Tiny bbox near south pole: lon-halving loop hits IEEE 754 convergence
+ ** before straddling the midpoint — old code hung here. */
+ bbox.xmin = -72.70493954792298;
+ bbox.xmax = -72.70493954792298;
+ bbox.ymin = -89.90561212126683;
+ bbox.ymax = -89.90561212126681;
+ precision = lwgeom_geohash_precision(bbox, &bounds);
+ CU_ASSERT(precision >= 0 && precision <= 20);
+
}
static void test_geohash_point(void)
@@ -981,7 +990,6 @@ static void test_geohash(void)
LWLINE *lwline = NULL;
LWMLINE *lwmline = NULL;
lwvarlena_t *geohash = NULL;
-
lwpoint = (LWPOINT*)lwgeom_from_wkt("POINT(23.0 25.2)", LW_PARSER_CHECK_NONE);
geohash = lwgeom_geohash((LWGEOM*)lwpoint,0);
//printf("\ngeohash %s\n",geohash);
diff --git a/liblwgeom/lwalgorithm.c b/liblwgeom/lwalgorithm.c
index 92a16d335..498e220ce 100644
--- a/liblwgeom/lwalgorithm.c
+++ b/liblwgeom/lwalgorithm.c
@@ -548,6 +548,8 @@ int lwline_crossing_direction(const LWLINE *l1, const LWLINE *l2)
static char *base32 = "0123456789bcdefghjkmnpqrstuvwxyz";
+#define GEOHASH_MAX_DOUBLE_PRECISION_CHARS 20
+
/*
** Calculate the geohash, iterating downwards and gaining precision.
** From geohash-native.c, (c) 2008 David Troy <dave at roundhousetech.com>
@@ -740,7 +742,7 @@ int lwgeom_geohash_precision(GBOX bbox, GBOX *bounds)
{
/* It's a point. Doubles have 51 bits of precision.
** 2 * 51 / 5 == 20 */
- return 20;
+ return GEOHASH_MAX_DOUBLE_PRECISION_CHARS;
}
lonmin = -180.0;
@@ -752,6 +754,11 @@ int lwgeom_geohash_precision(GBOX bbox, GBOX *bounds)
** bounds of our rectangle. */
while ( 1 )
{
+ double old_lonmin = lonmin;
+ double old_lonmax = lonmax;
+ double old_latmin = latmin;
+ double old_latmax = latmax;
+
lonwidth = lonmax - lonmin;
latwidth = latmax - latmin;
latmaxadjust = lonmaxadjust = latminadjust = lonminadjust = 0.0;
@@ -768,6 +775,9 @@ int lwgeom_geohash_precision(GBOX bbox, GBOX *bounds)
{
lonmin += lonminadjust;
lonmax += lonmaxadjust;
+ /* Stop before counting bits that no longer move the double bounds. */
+ if (lonmin == old_lonmin && lonmax == old_lonmax)
+ break;
/* Each adjustment cycle corresponds to 2 bits of storage in the
** geohash. */
precision++;
@@ -790,6 +800,9 @@ int lwgeom_geohash_precision(GBOX bbox, GBOX *bounds)
{
latmin += latminadjust;
latmax += latmaxadjust;
+ /* Stop before counting bits that no longer move the double bounds. */
+ if (latmin == old_latmin && latmax == old_latmax)
+ break;
/* Each adjustment cycle corresponds to 2 bits of storage in the
** geohash. */
precision++;
@@ -808,7 +821,8 @@ int lwgeom_geohash_precision(GBOX bbox, GBOX *bounds)
/* Each geohash character (base32) can contain 5 bits of information.
** We are returning the precision in characters, so here we divide. */
- return precision / 5;
+ precision /= 5;
+ return precision > GEOHASH_MAX_DOUBLE_PRECISION_CHARS ? GEOHASH_MAX_DOUBLE_PRECISION_CHARS : precision;
}
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
liblwgeom/cunit/cu_algorithm.c | 12 ++++++++++--
liblwgeom/lwalgorithm.c | 18 ++++++++++++++++--
3 files changed, 27 insertions(+), 4 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list