pgsql: Add pg_encoding_set_invalid() - Mailing list pgsql-committers

From Andres Freund
Subject pgsql: Add pg_encoding_set_invalid()
Date
Msg-id E1thVPw-006NxQ-IZ@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Add pg_encoding_set_invalid()

There are cases where we cannot / do not want to error out for invalidly
encoded input. In such cases it can be useful to replace e.g. an incomplete
multi-byte characters with bytes that will trigger an error when getting
validated as part of a larger string.

Unfortunately, until now, for some encoding no such sequence existed. For
those encodings this commit removes one previously accepted input combination
- we consider that to be ok, as the chosen bytes are outside of the valid
ranges for the encodings, we just previously failed to detect that.

As we cannot add a new field to pg_wchar_table without breaking ABI, this is
implemented "in-line" in the newly added function.

Author: Noah Misch <noah@leadboat.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Backpatch-through: 13
Security: CVE-2025-1094

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4dc28963533704fc7dd922b9447467466a233d89

Modified Files
--------------
src/common/wchar.c                       | 55 +++++++++++++++++++++++++++++++-
src/include/mb/pg_wchar.h                |  1 +
src/test/regress/expected/conversion.out |  7 ++++
src/test/regress/regress.c               | 50 +++++++++++++++++++++++++++++
src/test/regress/sql/conversion.sql      |  5 +++
5 files changed, 117 insertions(+), 1 deletion(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Translation updates
Next
From: Andres Freund
Date:
Subject: pgsql: Add test of various escape functions