pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Handle zero-length sublist correctly in Python -> SQL array conv
6+ messages / 1 participants
[nested] [flat]

* pgsql: Handle zero-length sublist correctly in Python -> SQL array conv
@ 2023-04-28 16:24 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2023-04-28 16:24 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/81eaaf65e393d03f49a781009fba876f81fe9d0b

Modified Files
--------------
src/pl/plpython/expected/plpython_types.out |  9 +++++++++
src/pl/plpython/plpy_typeio.c               | 23 +++++++----------------
src/pl/plpython/sql/plpython_types.sql      |  7 +++++++
3 files changed, 23 insertions(+), 16 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Handle zero-length sublist correctly in Python -> SQL array conv
@ 2023-04-28 16:24 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2023-04-28 16:24 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/512c555221c33f1791ee28a4cfeb929fcd957fdd

Modified Files
--------------
src/pl/plpython/expected/plpython_types.out |  9 +++++++++
src/pl/plpython/plpy_typeio.c               | 23 +++++++----------------
src/pl/plpython/sql/plpython_types.sql      |  7 +++++++
3 files changed, 23 insertions(+), 16 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Handle zero-length sublist correctly in Python -> SQL array conv
@ 2023-04-28 16:24 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2023-04-28 16:24 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_14_STABLE

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

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                 | 23 +++++++----------------
src/pl/plpython/sql/plpython_types.sql        |  7 +++++++
4 files changed, 32 insertions(+), 16 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Handle zero-length sublist correctly in Python -> SQL array conv
@ 2023-04-28 16:24 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2023-04-28 16:24 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7dcd9998c19d7e1a86bc0d76167e429455e3db5f

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Handle zero-length sublist correctly in Python -> SQL array conv
@ 2023-04-28 16:24 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2023-04-28 16:24 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_12_STABLE

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

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Handle zero-length sublist correctly in Python -> SQL array conv
@ 2023-04-28 16:24 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2023-04-28 16:24 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2023-04-28 16:24 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-04-28 16:24 pgsql: Handle zero-length sublist correctly in Python -> SQL array conv Tom Lane <tgl@sss.pgh.pa.us>
2023-04-28 16:24 pgsql: Handle zero-length sublist correctly in Python -> SQL array conv Tom Lane <tgl@sss.pgh.pa.us>
2023-04-28 16:24 pgsql: Handle zero-length sublist correctly in Python -> SQL array conv Tom Lane <tgl@sss.pgh.pa.us>
2023-04-28 16:24 pgsql: Handle zero-length sublist correctly in Python -> SQL array conv Tom Lane <tgl@sss.pgh.pa.us>
2023-04-28 16:24 pgsql: Handle zero-length sublist correctly in Python -> SQL array conv Tom Lane <tgl@sss.pgh.pa.us>
2023-04-28 16:24 pgsql: Handle zero-length sublist correctly in Python -> SQL array conv Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox