pgsql: Handle zero-length sublist correctly in Python -> SQL array conv

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Handle zero-length sublist correctly in Python -> SQL array conv
Дата
Msg-id E1psQtq-005MEa-E2@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Handle zero-length sublist correctly in Python -> SQL array conversion.

If PLySequence_ToArray came across a zero-length sublist, it'd compute
the overall array size as zero, possibly leading to a memory clobber.
(This would likely qualify as a security bug, were it not that plpython
is an untrusted language already.)

I think there are other corner-case issues in this code as well, notably
that the error messages don't match the core code and for some ranges
of array sizes you'd get "invalid memory alloc request size" rather than
the intended message about array size.

Really this code has no business doing its own array size calculation
at all, so remove the faulty code in favor of using ArrayGetNItems().

Per bug #17912 from Alexander Lakhin.  Bug seems to have come in with
commit 94aceed31, so back-patch to all supported branches.

Discussion: https://postgr.es/m/17912-82ceed78731d9cdc@postgresql.org

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b7c6af375da6fe75458233892fe57571348c2be0

Modified Files
--------------
src/pl/plpython/expected/plpython_types.out   |  9 +++++++++
src/pl/plpython/expected/plpython_types_3.out |  9 +++++++++
src/pl/plpython/plpy_typeio.c                 | 19 +++++++------------
src/pl/plpython/sql/plpython_types.sql        |  7 +++++++
4 files changed, 32 insertions(+), 12 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: pgsql: Fix crashes with CREATE SCHEMA AUTHORIZATION and schema elements
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Tighten array dimensionality checks in Perl -> SQL array convers