postgresql/src
Nathan Bossart e3a1f83eae Mark PQfn() unsafe and fix overrun in frontend LO interface.
When result_is_int is set to 0, PQfn() cannot validate that the
result fits in result_buf, so it will write data beyond the end of
the buffer when the server returns more data than requested.  Since
this function is insecurable and obsolete, add a warning to the top
of the pertinent documentation advising against its use.

The only in-tree caller of PQfn() is the frontend large object
interface.  To fix that, add a buf_size parameter to
pqFunctionCall3() that is used to protect against overruns, and use
it in a private version of PQfn() that also accepts a buf_size
parameter.

Reported-by: Yu Kunpeng <yu443940816@live.com>
Reported-by: Martin Heistermann <martin.heistermann@unibe.ch>
Author: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com>
Security: CVE-2026-6477
Backpatch-through: 14
2026-05-11 05:13:51 -07:00
..
backend Fix integer overflow in array_agg(), when the array grows too large 2026-05-11 05:13:51 -07:00
bin Prevent path traversal in pg_basebackup and pg_rewind 2026-05-11 05:13:50 -07:00
common Unify src/common/'s definitions of MaxAllocSize. 2026-05-11 05:13:50 -07:00
fe_utils In fmtIdEnc(), handle failure of enlargePQExpBuffer(). 2025-02-16 12:46:35 -05:00
include Prevent path traversal in pg_basebackup and pg_rewind 2026-05-11 05:13:50 -07:00
interfaces Mark PQfn() unsafe and fix overrun in frontend LO interface. 2026-05-11 05:13:51 -07:00
makefiles Refactor DLSUFFIX handling 2022-03-25 08:56:02 +01:00
pl Make plpgsql_trap test more robust and less resource-intensive. 2026-04-21 10:54:39 -04:00
port Prevent path traversal in pg_basebackup and pg_rewind 2026-05-11 05:13:50 -07:00
template On NetBSD, force dynamic symbol resolution at postmaster start. 2022-08-30 17:28:55 -04:00
test Check CREATE privilege on multirange type schema in CREATE TYPE. 2026-05-11 05:13:50 -07:00
timezone Guard against unsafe conditions in usage of pg_strftime(). 2026-05-11 05:13:50 -07:00
tools Add timingsafe_bcmp(), for constant-time memory comparison 2026-05-11 05:13:50 -07:00
tutorial Doc: sync src/tutorial/basics.source with SGML documentation. 2022-11-19 13:09:14 -05:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Don't put library-supplied -L/-I switches before user-supplied ones. 2025-07-29 15:17:41 -04:00
Makefile.shlib Stop using "-multiply_defined suppress" on macOS. 2023-09-26 21:06:21 -04:00
nls-global.mk Fix update-po for the PGXS case 2025-10-16 20:21:05 +02:00