agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
pgsql: pg_stat_statements: Fix buffer overflow with query normalization
3+ messages / 1 participants
[nested] [flat]

* pgsql: pg_stat_statements: Fix buffer overflow with query normalization
@ 2026-08-10 13:41 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Noah Misch @ 2026-08-10 13:41 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@kurilemu.de>
Reported-by: Sajeeb Lohani with TrendAI Zero Day Initiative
Reported-by: Yuelin Wang <3020001251@tju.edu.cn>
Diagnosed-by: Michaël Paquier <michael@paquier.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@kurilemu.de>

Modified Files
--------------
contrib/pg_stat_statements/pg_stat_statements.c | 44 +++++++++----------------
1 file changed, 16 insertions(+), 28 deletions(-)



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

* pgsql: pg_stat_statements: Fix buffer overflow with query normalization
@ 2026-08-10 13:41 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Noah Misch @ 2026-08-10 13:41 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@kurilemu.de>
Reported-by: Sajeeb Lohani with TrendAI Zero Day Initiative
Reported-by: Yuelin Wang <3020001251@tju.edu.cn>
Diagnosed-by: Michaël Paquier <michael@paquier.xyz>
Backpatch-through: 18
Security: CVE-2026-14676
Discussion: https://postgr.es/m/19528-7290dd7e6f7dcc22@postgresql.org

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/bb02eba534112594bc44a4b4c4fe9acb7ac7d656
Author: Álvaro Herrera <alvherre@kurilemu.de>

Modified Files
--------------
contrib/pg_stat_statements/pg_stat_statements.c | 44 +++++++++----------------
1 file changed, 16 insertions(+), 28 deletions(-)



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

* pgsql: pg_stat_statements: Fix buffer overflow with query normalization
@ 2026-08-10 13:41 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Noah Misch @ 2026-08-10 13:41 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@kurilemu.de>
Reported-by: Sajeeb Lohani with TrendAI Zero Day Initiative
Reported-by: Yuelin Wang <3020001251@tju.edu.cn>
Diagnosed-by: Michaël Paquier <michael@paquier.xyz>
Backpatch-through: 18
Security: CVE-2026-14676
Discussion: https://postgr.es/m/19528-7290dd7e6f7dcc22@postgresql.org

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8a31ffc2d4cc5e2f3fb42b6a41b7db802716615d
Author: Álvaro Herrera <alvherre@kurilemu.de>

Modified Files
--------------
contrib/pg_stat_statements/pg_stat_statements.c | 45 ++++++++++---------------
1 file changed, 17 insertions(+), 28 deletions(-)



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


end of thread, other threads:[~2026-08-10 13:41 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-08-10 13:41 pgsql: pg_stat_statements: Fix buffer overflow with query normalization Noah Misch <noah@leadboat.com>
2026-08-10 13:41 pgsql: pg_stat_statements: Fix buffer overflow with query normalization Noah Misch <noah@leadboat.com>
2026-08-10 13:41 pgsql: pg_stat_statements: Fix buffer overflow with query normalization Noah Misch <noah@leadboat.com>

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