[SCM] PostGIS branch stable-3.3 updated. 3.3.10-19-g1e3ded5af
git at osgeo.org
git at osgeo.org
Tue Jun 23 16:10:13 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.3 has been updated
via 1e3ded5af672e9b3746e10aa0af44bd2ef79920e (commit)
via 5104fcd170aeb681aa8c7ff0fc712bd70a459b70 (commit)
from 5802fcceacc56bc8f0bef8746c7f615a719fada7 (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 1e3ded5af672e9b3746e10aa0af44bd2ef79920e
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Jun 23 16:10:00 2026 -0700
New for avoid Inf loop in Geohash calculation
diff --git a/NEWS b/NEWS
index ad5468f05..d30e63a3d 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ PostGIS 3.3.11
- #5989, CurvePolygon distance corner case (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.3.10
commit 5104fcd170aeb681aa8c7ff0fc712bd70a459b70
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 67f3822a5..b34b149f9 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 1697320c1..61c145380 100644
--- a/liblwgeom/lwalgorithm.c
+++ b/liblwgeom/lwalgorithm.c
@@ -540,6 +540,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>
@@ -732,7 +734,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;
@@ -744,6 +746,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;
@@ -760,6 +767,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++;
@@ -782,6 +792,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++;
@@ -800,7 +813,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