postgresql/contrib/jsonb_plpython
Tom Lane 3df0b77558 jsonb_plperl, jsonb_plpython: Fix unguarded recursion and loops.
Add check_stack_depth() to Jsonb_to_SV, SV_to_JsonbValue,
PLyObject_FromJsonbContainer, and PLyObject_ToJsonbValue.  Without
this, deeply nested JSONB values can crash the backend with SIGSEGV
instead of raising a proper error.

Also add CHECK_FOR_INTERRUPTS() to the while loop in SV_to_JsonbValue
that dereferences chains of Perl references, so that a circular
reference (e.g. $x = \$x) can be cancelled by the user instead of
spinning indefinitely.  (We looked at detecting such circular
references, but it seems more trouble than it's worth.)

Author: Aleksander Alekseev <aleksander@tigerdata.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAJ7c6TPbjkzUk4qJ5dHvDNEz0hBuFue3A-XWz_=897z+BC+z8A@mail.gmail.com
Backpatch-through: 14
2026-06-17 11:04:41 -04:00
..
expected plpython: Remove regression test infrastructure for Python 2. 2022-03-07 18:20:51 -08:00
sql plpython: Remove regression test infrastructure for Python 2. 2022-03-07 18:20:51 -08:00
.gitignore plpython: Remove regression test infrastructure for Python 2. 2022-03-07 18:20:51 -08:00
jsonb_plpython.c jsonb_plperl, jsonb_plpython: Fix unguarded recursion and loops. 2026-06-17 11:04:41 -04:00
jsonb_plpython3u--1.0.sql Transforms for jsonb to PL/Python 2018-03-28 08:37:18 -04:00
jsonb_plpython3u.control Transforms for jsonb to PL/Python 2018-03-28 08:37:18 -04:00
Makefile plpython: Remove regression test infrastructure for Python 2. 2022-03-07 18:20:51 -08:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00