pgsql: Fix out-of-bound reads with ascii() for invalid multibyte charac

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix out-of-bound reads with ascii() for invalid multibyte charac
Date: 2026-08-10 13:41:29
Message-ID: E1wtQFt-00000000yHZ-412C@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix out-of-bound reads with ascii() for invalid multibyte characters

This commit addresses two defects in this SQL function, the code
assuming that:
- The user-supplied string was long enough to contain a character of the
length implied by the first byte. It is possible to provide in input
data that was able to disclose a few bytes of server memory, allowing
out-of-bound reads.
- Specific bytes had values within the expected range, using a set of
assertions to validate them. The assertions could be triggered on
invalid input. These are replaced by tests and error reports.

Reported-by: Hcamael <baiyjrh(at)gmail(dot)com>
Author: Michael Paquier <michael(at)paquier(dot)xyz>
Reviewed-by: Robert Haas <robertmhaas(at)gmail(dot)com>
Backpatch-through: 14
Security: CVE-2026-18024

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ac450853d5d0694a9071504d588dd60e28209198
Author: Michael Paquier <michael(at)paquier(dot)xyz>

Modified Files
--------------
src/backend/utils/adt/oracle_compat.c | 25 ++++++++++++++++++++-----
src/test/regress/expected/encoding.out | 19 +++++++++++++++++++
src/test/regress/sql/encoding.sql | 12 ++++++++++++
3 files changed, 51 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2026-08-10 13:41:30 pgsql: Reject calls from SQL to functions that take or return type inte
Previous Message Noah Misch 2026-08-10 13:41:28 pgsql: Harden tsvector code against overflows.