postgresql/contrib
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
..
amcheck Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
auth_delay Update copyright for 2026 2026-01-01 13:24:10 -05:00
auto_explain Pre-beta mechanical code beautification, step 2: run pgperltidy. 2026-05-13 10:37:42 -04:00
basebackup_to_shell Update copyright for 2026 2026-01-01 13:24:10 -05:00
basic_archive Fix dereference in a couple of GUC check hooks 2026-03-24 16:45:39 +01:00
bloom Discount the metapage when estimating number of index pages visited. 2026-03-20 14:50:53 -04:00
bool_plperl Update copyright for 2026 2026-01-01 13:24:10 -05:00
btree_gin Use fallthrough attribute instead of comment 2026-02-19 08:51:12 +01:00
btree_gist Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
citext Update copyright for 2026 2026-01-01 13:24:10 -05:00
cube Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
dblink Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
dict_int Update copyright for 2026 2026-01-01 13:24:10 -05:00
dict_xsyn Replace pg_mblen() with bounds-checked versions. 2026-02-09 12:44:04 +13:00
earthdistance Update copyright for 2026 2026-01-01 13:24:10 -05:00
file_fdw file_fdw: Add regression test for file_fdw with ON_ERROR='set_null' 2026-03-16 12:13:11 +09:00
fuzzystrmatch Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
hstore Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
hstore_plperl Use palloc_array() in a few more places to avoid overflow 2026-05-11 21:27:55 +03:00
hstore_plpython Use palloc_array() in a few more places to avoid overflow 2026-05-11 21:27:55 +03:00
intagg Update copyright for 2026 2026-01-01 13:24:10 -05:00
intarray Re-add regression tests for ltree and intarray 2026-05-15 14:27:30 +09:00
isn Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
jsonb_plperl Harmonize function parameter names for Postgres 19. 2026-04-22 12:47:19 -04:00
jsonb_plpython Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
lo Update copyright for 2026 2026-01-01 13:24:10 -05:00
ltree Re-add regression tests for ltree and intarray 2026-05-15 14:27:30 +09:00
ltree_plpython Change StaticAssertVariableIsOfType to be a declaration 2026-02-03 08:46:02 +01:00
oid2name Use pg_malloc_object() and pg_alloc_array() variants in frontend code 2026-02-27 18:59:41 +09:00
pageinspect Adjust some incorrect *GetDatum() macros 2026-04-30 13:10:19 +09:00
passwordcheck Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_buffercache Adjust some incorrect *GetDatum() macros 2026-04-30 13:10:19 +09:00
pg_freespacemap Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_logicalinspect Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_overexplain Fix a set of typos and grammar issues across the tree 2026-04-21 14:46:22 +09:00
pg_plan_advice Fix a set of typos and grammar issues across the tree 2026-04-21 14:46:22 +09:00
pg_prewarm Pre-beta mechanical code beautification, step 2: run pgperltidy. 2026-05-13 10:37:42 -04:00
pg_stash_advice Pre-beta mechanical code beautification, step 2: run pgperltidy. 2026-05-13 10:37:42 -04:00
pg_stat_statements pg_stat_statements: Set PlannedStmt to NULL after nested utility execution 2026-05-13 15:39:44 +09:00
pg_surgery Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_trgm Avoid casting void * function arguments 2026-04-23 08:08:57 +02:00
pg_visibility Allow logical replication snapshots to be database-specific 2026-04-07 12:31:18 +02:00
pg_walinspect Report detailed errors from XLogFindNextRecord() failures. 2026-03-24 22:33:09 +09:00
pgcrypto Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
pgrowlocks Thread flags through begin-scan APIs 2026-03-30 12:27:24 -04:00
pgstattuple pgstattuple: Optimize pgstattuple_approx() with streaming read 2026-03-14 15:06:13 +09:00
postgres_fdw postgres_fdw: Replace buffers in RemoteAttributeMapping with pointers. 2026-05-16 17:55:00 +09:00
seg Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
sepgsql Harmonize function parameter names for Postgres 19. 2026-04-22 12:47:19 -04:00
spi refint: Fix segfault in check_foreign_key(). 2026-05-14 13:11:49 -05:00
sslinfo Update copyright for 2026 2026-01-01 13:24:10 -05:00
start-scripts Remove gratuitous references to postmaster program 2023-01-26 10:48:32 +01:00
tablefunc Avoid including vacuum.h in tableam.h and heapam.h. 2026-03-31 12:43:52 -05:00
tcn Update copyright for 2026 2026-01-01 13:24:10 -05:00
test_decoding Don't lose column values on REPACK 2026-05-05 10:24:49 +02:00
tsm_system_rows Update copyright for 2026 2026-01-01 13:24:10 -05:00
tsm_system_time Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
unaccent Update Unicode data to Unicode 17.0.0 2026-03-20 08:42:50 +01:00
uuid-ossp Fix accidentally cast away qualifiers 2026-01-26 16:02:31 +01:00
vacuumlo Update copyright for 2026 2026-01-01 13:24:10 -05:00
xml2 Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
contrib-global.mk Respect TEMP_CONFIG when pg_regress_check and friends are called 2016-02-27 12:28:21 -05:00
Makefile Add pg_stash_advice contrib module. 2026-04-06 07:41:28 -04:00
meson.build Add pg_stash_advice contrib module. 2026-04-06 07:41:28 -04:00
README Rename 'gmake' to 'make' in docs and recommended commands 2014-02-12 17:29:19 -05:00

The PostgreSQL contrib tree
---------------------------

This subtree contains porting tools, analysis utilities, and plug-in
features that are not part of the core PostgreSQL system, mainly
because they address a limited audience or are too experimental to be
part of the main source tree.  This does not preclude their
usefulness.

User documentation for each module appears in the main SGML
documentation.

When building from the source distribution, these modules are not
built automatically, unless you build the "world" target.  You can
also build and install them all by running "make all" and "make
install" in this directory; or to build and install just one selected
module, do the same in that module's subdirectory.

Some directories supply new user-defined functions, operators, or
types.  To make use of one of these modules, after you have installed
the code you need to register the new SQL objects in the database
system by executing a CREATE EXTENSION command.  In a fresh database,
you can simply do

    CREATE EXTENSION module_name;

See the PostgreSQL documentation for more information about this
procedure.