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:28
Message-ID: E1wtQFs-00000000yF7-2M3u@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_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/849da82105395fa4d06f877db8edc62158167941
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:29 pgsql: Add an output_plugin_libraries GUC to bless trusted output plugi
Previous Message Noah Misch 2026-08-10 13:41:27 pgsql: Preserve the owner of extended statistics rebuilt by ALTER TABLE