postgresql/src/fe_utils
Andres Freund 5dc1e42b4f Fix handling of invalidly encoded data in escaping functions
Previously invalidly encoded input to various escaping functions could lead to
the escaped string getting incorrectly parsed by psql.  To be safe, escaping
functions need to ensure that neither invalid nor incomplete multi-byte
characters can be used to "escape" from being quoted.

Functions which can report errors now return an error in more cases than
before. Functions that cannot report errors now replace invalid input bytes
with a byte sequence that cannot be used to escape the quotes and that is
guaranteed to error out when a query is sent to the server.

The following functions are fixed by this commit:
- PQescapeLiteral()
- PQescapeIdentifier()
- PQescapeString()
- PQescapeStringConn()
- fmtId()
- appendStringLiteral()

Reported-by: Stephen Fewer <stephen_fewer@rapid7.com>
Reviewed-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 13
Security: CVE-2025-1094
2025-02-10 10:03:37 -05:00
..
.gitignore Move psql's psqlscan.l into src/fe_utils. 2016-03-24 20:28:47 -04:00
archive.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
astreamer_file.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
astreamer_gzip.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
astreamer_lz4.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
astreamer_tar.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
astreamer_zstd.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
cancel.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
conditional.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
connect_utils.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
Makefile Drop warning-free support for Flex 2.5.35 2025-01-15 15:35:08 +01:00
mbprint.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
meson.build Drop warning-free support for Flex 2.5.35 2025-01-15 15:35:08 +01:00
option_utils.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
parallel_slot.c Fix grammatical typos around possessive "its" 2025-01-29 14:39:14 +07:00
print.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
psqlscan.l Drop warning-free support for Flex 2.5.35 2025-01-15 15:35:08 +01:00
query_utils.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
recovery_gen.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
simple_list.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
string_utils.c Fix handling of invalidly encoded data in escaping functions 2025-02-10 10:03:37 -05:00