pgsql: Fix mb2wchar functions on short input. - Mailing list pgsql-committers

From Thomas Munro
Subject pgsql: Fix mb2wchar functions on short input.
Date
Msg-id E1vpEoc-001x3S-11@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix mb2wchar functions on short input.

When converting multibyte to pg_wchar, the UTF-8 implementation would
silently ignore an incomplete final character, while the other
implementations would cast a single byte to pg_wchar, and then repeat
for the remaining byte sequence.  While it didn't overrun the buffer, it
was surely garbage output.

Make all encodings behave like the UTF-8 implementation.  A later change
for master only will convert this to an error, but we choose not to
back-patch that behavior change on the off-chance that someone is
relying on the existing UTF-8 behavior.

Security: CVE-2026-2006
Backpatch-through: 14
Author: Thomas Munro <thomas.munro@gmail.com>
Reported-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>

Branch
------
REL_16_STABLE

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

Modified Files
--------------
src/common/wchar.c | 52 ++++++++++++++++++++++++++++++++--------------------
1 file changed, 32 insertions(+), 20 deletions(-)


pgsql-committers by date:

Previous
From: Thomas Munro
Date:
Subject: pgsql: Fix encoding length for EUC_CN.
Next
From: Thomas Munro
Date:
Subject: pgsql: Fix mb2wchar functions on short input.