postgresql/src/interfaces/libpq
Tom Lane c08309584a Make escaping functions retain trailing bytes of an invalid character.
Instead of dropping the trailing byte(s) of an invalid or incomplete
multibyte character, replace only the first byte with a known-invalid
sequence, and process the rest normally.  This seems less likely to
confuse incautious callers than the behavior adopted in 5dc1e42b4.

While we're at it, adjust PQescapeStringInternal to produce at most
one bleat about invalid multibyte characters per string.  This
matches the behavior of PQescapeInternal, and avoids the risk of
producing tons of repetitive junk if a long string is simply given
in the wrong encoding.

This is a followup to the fixes for CVE-2025-1094, and should be
included if cherry-picking those fixes.

Author: Andres Freund <andres@anarazel.de>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Reported-by: Jeff Davis <pgsql@j-davis.com>
Discussion: https://postgr.es/m/20250215012712.45@rfd.leadboat.com
Backpatch-through: 13
2025-02-15 16:20:21 -05:00
..
po Translation updates 2025-02-10 15:16:57 +01:00
test Remove extraneous newlines added by perl copyright patch 2021-05-07 11:37:37 -04:00
.gitignore Move wchar.c and encnames.c to src/common/. 2020-01-16 15:58:55 -05:00
exports.txt Add PQsendFlushRequest to libpq 2021-06-29 14:37:39 -04:00
fe-auth-scram.c Fix comment in fe-auth-scram.c 2022-11-30 08:38:30 +09:00
fe-auth.c Revert error handling improvements for cryptohashes 2022-01-14 11:25:39 +09:00
fe-auth.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
fe-connect.c libpq: Bail out during SSL/GSS negotiation errors 2024-11-11 10:20:01 +09:00
fe-exec.c Make escaping functions retain trailing bytes of an invalid character. 2025-02-15 16:20:21 -05:00
fe-gssapi-common.c Don't assume GSSAPI result strings are null-terminated. 2021-06-23 14:01:32 -04:00
fe-gssapi-common.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
fe-lobj.c Remove server and libpq support for old FE/BE protocol version 2. 2021-03-04 10:45:55 +02:00
fe-misc.c Avoid concurrent calls to bindtextdomain(). 2024-02-09 11:21:08 -05:00
fe-print.c Don't use abort(3) in libpq's fe-print.c. 2021-06-28 14:17:42 -04:00
fe-protocol3.c Fix handling of errors in libpq pipelines 2023-12-05 12:43:24 +01:00
fe-secure-common.c In libpq, always append new error messages to conn->errorMessage. 2021-01-11 13:12:09 -05:00
fe-secure-common.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
fe-secure-gssapi.c Fix timing-dependent failure in GSSAPI data transmission. 2023-11-23 13:30:18 -05:00
fe-secure-openssl.c libpq: Use strerror_r instead of strerror 2024-07-28 09:26:21 +02:00
fe-secure.c Be more wary about OpenSSL not setting errno on error. 2023-12-11 11:51:56 -05:00
fe-trace.c Rename PQtraceSetFlags() to PQsetTraceFlags(). 2021-06-10 21:56:13 -07: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 2021 2021-01-02 13:06:25 -05:00
libpq-events.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
libpq-fe.h Add PQsendFlushRequest to libpq 2021-06-29 14:37:39 -04:00
libpq-int.h Fix handling of errors in libpq pipelines 2023-12-05 12:43:24 +01:00
Makefile libpq: Fix pkg-config without OpenSSL 2022-04-01 17:12:56 +02:00
nls.mk Translation updates 2021-09-20 16:23:13 +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 2021 2021-01-02 13:06:25 -05:00
pqexpbuffer.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pthread-win32.c Clean up Windows-specific mutex code in libpq and ecpglib. 2024-02-09 11:11:39 -05:00
README Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
win32.c Update copyright for 2021 2021-01-02 13:06:25 -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.