aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/geo_ops.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-08-24 13:01:40 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-08-24 13:02:19 -0400
commit3d3c05c70fc7c1ce7794ebff55aa251a589de851 (patch)
tree635d16eb5314e1d8579f318dc223cf88ed30bad7 /src/backend/utils/adt/geo_ops.c
parente6828053d9d62aab68f74d0f3a024db10a4ce5fd (diff)
downloadpostgresql-3d3c05c70fc7c1ce7794ebff55aa251a589de851.tar.gz
postgresql-3d3c05c70fc7c1ce7794ebff55aa251a589de851.zip
Defend against stack overrun in a few more places.
SplitToVariants() in the ispell code, lseg_inside_poly() in geo_ops.c, and regex_selectivity_sub() in selectivity estimation could recurse until stack overflow; fix by adding check_stack_depth() calls. So could next() in the regex compiler, but that case is better fixed by converting its tail recursion to a loop. (We probably get better code that way too, since next() can now be inlined into its sole caller.) There remains a reachable stack overrun in the Turkish stemmer, but we'll need some advice from the Snowball people about how to fix that. Per report from Egor Chindyaskin and Alexander Lakhin. These mistakes are old, so back-patch to all supported branches. Richard Guo and Tom Lane Discussion: https://postgr.es/m/1661334672.728714027@f473.i.mail.ru
Diffstat (limited to 'src/backend/utils/adt/geo_ops.c')
-rw-r--r--src/backend/utils/adt/geo_ops.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c
index b79705f8b3f..535301a2180 100644
--- a/src/backend/utils/adt/geo_ops.c
+++ b/src/backend/utils/adt/geo_ops.c
@@ -3833,6 +3833,9 @@ lseg_inside_poly(Point *a, Point *b, POLYGON *poly, int start)
bool res = true,
intersection = false;
+ /* since this function recurses, it could be driven to stack overflow */
+ check_stack_depth();
+
t.p[0] = *a;
t.p[1] = *b;
s.p[0] = poly->p[(start == 0) ? (poly->npts - 1) : (start - 1)];