| From: | Noah Misch <noah(at)leadboat(dot)com> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: pg_stat_statements: Fix buffer overflow with query normalization |
| Date: | 2026-08-10 13:41:20 |
| Message-ID: | E1wtQFk-00000000y14-0MPA@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
pg_stat_statements: Fix buffer overflow with query normalization
Since commit 62d712ecfd94, pg_stat_statements has been underestimating
the size of the result buffer possible for a normalized query, in cases
where the query includes many squashable lists, causing the normalized
query to write past the allocated area.
The allocated buffer size forgot to account for the comment appended in
a squashable list, "/*, ... */". Instead of trying to track down
precisely how much space we need, fix by switch to using an expansible
StringInfo. This not only fixes the bug, but it also makes the code
simpler to follow.
Author: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Reported-by: Sajeeb Lohani with TrendAI Zero Day Initiative
Reported-by: Yuelin Wang <3020001251(at)tju(dot)edu(dot)cn>
Diagnosed-by: Michaël Paquier <michael(at)paquier(dot)xyz>
Backpatch-through: 18
Security: CVE-2026-14676
Discussion: https://postgr.es/m/19528-7290dd7e6f7dcc22@postgresql.org
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/1e2795ddeafc66cd78d2c90a69dd820488639c7c
Author: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Modified Files
--------------
contrib/pg_stat_statements/pg_stat_statements.c | 44 +++++++++----------------
1 file changed, 16 insertions(+), 28 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Noah Misch | 2026-08-10 13:41:21 | pgsql: Replace fixed-size, too-short array with a palloc'd one. |
| Previous Message | Noah Misch | 2026-08-10 13:41:19 | pgsql: pg_dump: avoid assuming how long pg_proc.protrftypes can be. |