postgresql/contrib/postgres_fdw
Etsuro Fujita aa1f93a338 postgres_fdw: Replace buffers in RemoteAttributeMapping with pointers.
Commit 28972b6fc ("Add support for importing statistics from remote
servers.") stored the names of local/remote columns for a foreign table
into the buffers of NAMEDATALEN bytes in this structure, without
accounting for the possibility that the remote column name in particular
could be longer than NAMEDATALEN - 1.  If it was longer than that, this
would leave it unterminated/truncated in the buffer, invoking undefined
behavior when match_attrmap() processes it, which assumes that it's
fully-contained/terminated in the buffer.

To fix, replace the buffers with char pointers, pstrdup the local/remote
column names, and store the results into the pointers.  This commit also
adds a function to clean up the nested data structure.

Per Coverity and Tom Lane.

Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Author: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com>
Discussion: https://postgr.es/m/342868.1776017700%40sss.pgh.pa.us
2026-05-16 17:55:00 +09:00
..
expected postgres_fdw: Fix deparsing of remote column names in stats import. 2026-05-14 17:05:00 +09:00
specs postgres_fdw: Add more test coverage for EvalPlanQual testing. 2025-11-06 12:15:00 +09:00
sql postgres_fdw: Fix deparsing of remote column names in stats import. 2026-05-14 17:05:00 +09:00
t ALTER SUBSCRIPTION ... SERVER test. 2026-03-18 10:15:51 -07:00
.gitignore Fix EvalPlanQual handling of foreign/custom joins in ExecScanFetch. 2025-10-15 17:15:00 +09:00
connection.c postgres_fdw: Fix handling of abort-cleanup-failed connections. 2026-05-05 18:55:00 +09:00
deparse.c Add support for importing statistics from remote servers. 2026-04-08 19:15:00 +09:00
Makefile CREATE SUBSCRIPTION ... SERVER. 2026-03-06 08:27:56 -08:00
meson.build CREATE SUBSCRIPTION ... SERVER. 2026-03-06 08:27:56 -08:00
option.c Add support for importing statistics from remote servers. 2026-04-08 19:15:00 +09:00
postgres_fdw--1.0--1.1.sql postgres_fdw: Add functions to discard cached connections. 2021-01-26 15:35:54 +09:00
postgres_fdw--1.0.sql Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
postgres_fdw--1.1--1.2.sql postgres_fdw: Extend postgres_fdw_get_connections to return remote backend PID. 2025-03-03 08:51:30 +09:00
postgres_fdw--1.2--1.3.sql CREATE SUBSCRIPTION ... SERVER. 2026-03-06 08:27:56 -08:00
postgres_fdw.c postgres_fdw: Replace buffers in RemoteAttributeMapping with pointers. 2026-05-16 17:55:00 +09:00
postgres_fdw.control CREATE SUBSCRIPTION ... SERVER. 2026-03-06 08:27:56 -08:00
postgres_fdw.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
shippable.c Switch SysCacheIdentifier to a typedef enum 2026-02-18 09:58:38 +09:00