postgresql/src/interfaces/libpq
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
..
po Update copyright for 2025 2025-01-01 11:21:55 -05:00
t Update copyright for 2025 2025-01-01 11:21:55 -05:00
test meson: Add missing dependencies for libpq tests 2025-02-04 17:56:19 -05:00
.gitignore Run tap tests in src/interfaces/libpq. 2022-02-26 16:51:47 -08:00
exports.txt libpq: Add service name to PGconn and PQservice() 2024-12-18 14:53:42 +09:00
fe-auth-sasl.h libpq: Handle asynchronous actions during SASL 2025-02-06 22:19:21 +01:00
fe-auth-scram.c libpq: Handle asynchronous actions during SASL 2025-02-06 22:19:21 +01:00
fe-auth.c libpq: Handle asynchronous actions during SASL 2025-02-06 22:19:21 +01:00
fe-auth.h libpq: Handle asynchronous actions during SASL 2025-02-06 22:19:21 +01:00
fe-cancel.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
fe-connect.c libpq: Handle asynchronous actions during SASL 2025-02-06 22:19:21 +01:00
fe-exec.c Fix handling of invalidly encoded data in escaping functions 2025-02-10 10:03:37 -05:00
fe-gssapi-common.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
fe-gssapi-common.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
fe-lobj.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
fe-misc.c libpq: Handle asynchronous actions during SASL 2025-02-06 22:19:21 +01:00
fe-print.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
fe-protocol3.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
fe-secure-common.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
fe-secure-common.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
fe-secure-gssapi.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
fe-secure-openssl.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
fe-secure.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
fe-trace.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
legacy-pqsignal.c Avoid symbol collisions between pqsignal.c and legacy-pqsignal.c. 2025-01-14 18:50:24 -05:00
libpq-events.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
libpq-events.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
libpq-fe.h libpq: Handle asynchronous actions during SASL 2025-02-06 22:19:21 +01:00
libpq-int.h libpq: Handle asynchronous actions during SASL 2025-02-06 22:19:21 +01:00
Makefile Remove support for linking with libeay32 and ssleay32 2025-02-06 20:26:46 +01:00
meson.build meson: Add missing dependencies for libpq tests 2025-02-04 17:56:19 -05:00
nls.mk More use of getpwuid_r() directly 2024-09-02 09:04:30 +02:00
pg_service.conf.sample Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
pqexpbuffer.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
pqexpbuffer.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
pthread-win32.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
README Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
win32.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
win32.h Recognize network-failure errnos as indicating hard connection loss. 2020-10-10 13:28:12 -04:00

src/interfaces/libpq/README

This directory contains the C version of Libpq, the POSTGRES frontend library.