postgresql/src/common
Thomas Munro af79c30dc3 Fix encoding length for EUC_CN.
While EUC_CN supports only 1- and 2-byte sequences (CS0, CS1), the
mb<->wchar conversion functions allow 3-byte sequences beginning SS2,
SS3.

Change pg_encoding_max_length() to return 3, not 2, to close a
hypothesized buffer overrun if a corrupted string is converted to wchar
and back again in a newly allocated buffer.  We might reconsider that in
master (ie harmonizing in a different direction), but this change seems
better for the back-branches.

Also change pg_euccn_mblen() to report SS2 and SS3 characters as having
length 3 (following the example of EUC_KR).  Even though such characters
would not pass verification, it's remotely possible that invalid bytes
could be used to compute a buffer size for use in wchar conversion.

Security: CVE-2026-2006
Backpatch-through: 14
Author: Thomas Munro <thomas.munro@gmail.com>
Reviewed-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
2026-02-09 12:08:58 +13:00
..
unicode Fix accidentally cast away qualifiers 2026-01-26 16:02:31 +01:00
.gitignore Replace the data structure used for keyword lookup. 2019-01-06 17:02:57 -05:00
archive.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
base64.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
binaryheap.c Remove #include <math.h> where not needed 2026-01-15 19:09:47 +01:00
blkreftable.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
checksum_helper.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
compression.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
config_info.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
controldata_utils.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
cryptohash.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
cryptohash_openssl.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
d2s.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
d2s_full_table.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
d2s_intrinsics.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
digit_table.h Change floating-point output format for improved performance. 2019-02-13 15:20:33 +00:00
encnames.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
exec.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
f2s.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
fe_memutils.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
file_perm.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
file_utils.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
hashfn.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
hmac.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
hmac_openssl.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
ip.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
jsonapi.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
keywords.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
kwlookup.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
link-canary.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
logging.c Revert "Replace pg_restrict by standard restrict" 2026-01-14 15:12:25 +01:00
Makefile Don't put library-supplied -L/-I switches before user-supplied ones. 2025-07-29 15:17:40 -04:00
md5.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
md5_common.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
md5_int.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
meson.build Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_manifest.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
percentrepl.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_get_line.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_lzcompress.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_prng.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
pgfnames.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
psprintf.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
relpath.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
restricted_token.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
rmtree.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
ryu_common.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
saslprep.c Separate read and write pointers in pg_saslprep 2026-01-05 11:03:49 +01:00
scram-common.c Fix accidentally cast away qualifiers 2026-01-26 16:02:31 +01:00
sha1.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
sha1_int.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
sha2.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
sha2_int.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
sprompt.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
string.c Revert "Replace pg_restrict by standard restrict" 2026-01-14 15:12:25 +01:00
stringinfo.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
unicode_case.c Fix accidentally cast away qualifiers 2026-01-26 16:02:31 +01:00
unicode_category.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
unicode_norm.c Fix misc typos, mostly in comments 2026-01-08 18:10:08 +02:00
username.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
wait_error.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
wchar.c Fix encoding length for EUC_CN. 2026-02-09 12:08:58 +13:00