| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: hstore: Rework module to use Size and {add,mul}_size for allocat |
| Date: | 2026-08-18 04:44:52 |
| Message-ID: | E1wwBgx-000000010ko-1nxP@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
hstore: Rework module to use Size and {add,mul}_size for allocation sizes
hstore has been relying on a set of int/int32 to count the total length
of all the keys and values constructed, relying on the maximum values of
the arguments rather than proper bound checks. As proved in the
reported thread, these counters could overflow and wrap, leading to
incorrect allocations.
This commit replaces the int/int32 values with a set of Size values,
with add_size() and mul_size() in charge of checking for overflows when
constructing hstore values before doing any allocation.
The changes that matter in terms of the report are mostly in
hstore_io.c. hstore_compat.c is adjusted for consistency, to keep the
allocation maths uniform across the module.
This is an old bug. A backpatch should perhaps be done but I cannot get
excited about a change like that in stable branches.
Reported-by: Man Zeng <zengman(at)halodbtech(dot)com>
Author: Tender Wang <tndrwang(at)gmail(dot)com>
Author: Michael Paquier <michael(at)paquier(dot)xyz>
Discussion: https://postgr.es/m/CAHewXNmfD6-9MDxgpRfTzjVj0mhBw3JMoNOHeTiPOjZGhNzd=g@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/92e20d4a4382810a30bdb394473d6ee891edab73
Modified Files
--------------
contrib/hstore/hstore.h | 33 ++++++++++-------
contrib/hstore/hstore_compat.c | 29 +++++++--------
contrib/hstore/hstore_io.c | 60 +++++++++++++++++++++----------
contrib/hstore/hstore_op.c | 12 +++----
contrib/hstore/hstore_subs.c | 4 +--
contrib/hstore_plperl/hstore_plperl.c | 6 ++--
contrib/hstore_plpython/hstore_plpython.c | 6 ++--
7 files changed, 91 insertions(+), 59 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-08-18 06:36:38 | pgsql: doc: Fix description of log_line_prefix %L in release notes |
| Previous Message | Amit Langote | 2026-08-18 03:42:01 | pgsql: Fix cross-type foreign keys in the batched fast-path FK check |