From b1756da7541323eae07fe23eaad17ce12f20a56b Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Mon, 10 Feb 2025 10:03:39 -0500 Subject: Specify the encoding of input to fmtId() This commit adds fmtIdEnc() and fmtQualifiedIdEnc(), which allow to specify the encoding as an explicit argument. Additionally setFmtEncoding() is provided, which defines the encoding when no explicit encoding is provided, to avoid breaking all code using fmtId(). All users of fmtId()/fmtQualifiedId() are either converted to the explicit version or a call to setFmtEncoding() has been added. This commit does not yet utilize the now well-defined encoding, that will happen in a subsequent commit. Reviewed-by: Noah Misch Reviewed-by: Tom Lane Backpatch-through: 13 Security: CVE-2025-1094 --- src/include/fe_utils/string_utils.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/include/fe_utils/string_utils.h') diff --git a/src/include/fe_utils/string_utils.h b/src/include/fe_utils/string_utils.h index fa4deb24978..92b2b2d3083 100644 --- a/src/include/fe_utils/string_utils.h +++ b/src/include/fe_utils/string_utils.h @@ -25,7 +25,10 @@ extern PQExpBuffer (*getLocalPQExpBuffer) (void); /* Functions */ extern const char *fmtId(const char *identifier); +extern const char *fmtIdEnc(const char *identifier, int encoding); extern const char *fmtQualifiedId(const char *schema, const char *id); +extern const char *fmtQualifiedIdEnc(const char *schema, const char *id, int encoding); +extern void setFmtEncoding(int encoding); extern char *formatPGVersionNumber(int version_number, bool include_minor, char *buf, size_t buflen); -- cgit v1.2.3