aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2025-02-10 10:03:39 -0500
committerAndres Freund <andres@anarazel.de>2025-02-10 10:03:39 -0500
commit703b3fd5de5d7bfe9cb3948601bc165da024256d (patch)
tree50fd8781dd037994c442b29eff3a2727e2241b32 /src/include
parent0fb459877a429f7e934bff4acd6c853b2e47515c (diff)
downloadpostgresql-703b3fd5de5d7bfe9cb3948601bc165da024256d.tar.gz
postgresql-703b3fd5de5d7bfe9cb3948601bc165da024256d.zip
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
Diffstat (limited to 'src/include')
-rw-r--r--src/include/mb/pg_wchar.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h
index 4a0e6bfbccd..0e9e412a82e 100644
--- a/src/include/mb/pg_wchar.h
+++ b/src/include/mb/pg_wchar.h
@@ -573,6 +573,7 @@ extern int pg_valid_server_encoding_id(int encoding);
* (in addition to the ones just above). The constant tables declared
* earlier in this file are also available from libpgcommon.
*/
+extern void pg_encoding_set_invalid(int encoding, char *dst);
extern int pg_encoding_mblen(int encoding, const char *mbstr);
extern int pg_encoding_mblen_bounded(int encoding, const char *mbstr);
extern int pg_encoding_dsplen(int encoding, const char *mbstr);