| From: | Fujii Masao <fujii(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: postgres_fdw: Fix possible crash after option initialization fai |
| Date: | 2026-11-12 00:25:40 |
| Message-ID: | E1xRIdI-00000000NB2-0tpV@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
postgres_fdw: Fix possible crash after option initialization fails
An out-of-memory error while initializing postgres_fdw's option array
could cause a later operation using postgres_fdw in the same session
to crash.
InitPgFdwOptions() assigned postgres_fdw_options before filling the
array. If MemoryContextStrdup() failed while copying an option name,
the pointer remained non-NULL, causing subsequent calls to skip
initialization and use the incomplete array.
Fix this by building the array using a local pointer and assign
postgres_fdw_options only after initialization is complete, so that
a failed attempt can be retried safely.
Backpatch to v19, where commit 0f9d4d7c12d introduced the
MemoryContextStrdup() calls that made this failure possible.
Author: Lucas Jeffrey <luquijeffrey(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAObkL7OzJWqNg170qM=+zQjw1-EyvKc8LjWizjcnw4fEjB5mnw@mail.gmail.com
Backpatch-through: 19
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/1d4324a2a302514a24908435dede693cff81fa37
Modified Files
--------------
contrib/postgres_fdw/option.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2026-11-12 00:25:53 | pgsql: postgres_fdw: Fix possible crash after option initialization fai |
| Previous Message | Tom Lane | 2026-11-11 22:45:08 | pgsql: Fix incorrect early exit from contain_mutable_functions_walker. |