pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add pg_encoding_set_invalid()
Date: Mon, 10 Feb 2025 15:09:49 +0000
Message-ID: <E1thVPw-006Nyc-W4@gemulon.postgresql.org> (raw)

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
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/db3eb0e8256a7089d16cb6ed1ea7a65654c0e105

Modified Files
--------------
src/common/wchar.c                               | 55 +++++++++++++++++++++++-
src/include/mb/pg_wchar.h                        |  3 +-
src/test/regress/expected/conversion.out         |  4 ++
src/test/regress/input/create_function_1.source  |  4 ++
src/test/regress/output/create_function_1.source |  3 ++
src/test/regress/regress.c                       | 51 ++++++++++++++++++++++
src/test/regress/sql/conversion.sql              |  3 ++
7 files changed, 121 insertions(+), 2 deletions(-)



view thread (6+ messages)

Message-ID: <E1thVPw-006Nyc-W4@gemulon.postgresql.org>
Permalink:  ../E1thVPw-006Nyc-W4@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1thVPw-006Nyc-W4@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add pg_encoding_set_invalid()
  In-Reply-To: <E1thVPw-006Nyc-W4@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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