pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix libpq crashes on malformed target_session_attrs query result 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix libpq crashes on malformed target_session_attrs query result @ 2026-11-21 14:19 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Fujii Masao @ 2026-11-21 14:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix libpq crashes on malformed target_session_attrs query results Applications using libpq could crash during connection establishment when a server returned an unexpected result for an internal query used to check target_session_attrs. This happened because libpq checked that the result contained one row, but did not check the column count before reading the first column. A result with one row and no columns caused PQgetvalue() to return NULL, which was then passed to strncmp(). Fix this by requiring exactly one column in the results of SHOW transaction_read_only and SELECT pg_catalog.pg_is_in_recovery(). Malformed results now follow the existing error path, rejecting the connection attempt to that host and trying the next host, if any. Backpatch to all supported versions. Author: s1ko <s1ko@riseup.net> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/f1743511-5fab-482e-94ec-1198ce18723e@riseup.net Backpatch-through: 15 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/af24adce91dbbc02d194163b994f1d8346831573 Modified Files -------------- src/interfaces/libpq/fe-connect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix libpq crashes on malformed target_session_attrs query result @ 2026-11-21 14:19 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Fujii Masao @ 2026-11-21 14:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix libpq crashes on malformed target_session_attrs query results Applications using libpq could crash during connection establishment when a server returned an unexpected result for an internal query used to check target_session_attrs. This happened because libpq checked that the result contained one row, but did not check the column count before reading the first column. A result with one row and no columns caused PQgetvalue() to return NULL, which was then passed to strncmp(). Fix this by requiring exactly one column in the results of SHOW transaction_read_only and SELECT pg_catalog.pg_is_in_recovery(). Malformed results now follow the existing error path, rejecting the connection attempt to that host and trying the next host, if any. Backpatch to all supported versions. Author: s1ko <s1ko@riseup.net> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/f1743511-5fab-482e-94ec-1198ce18723e@riseup.net Backpatch-through: 15 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/fa52beefacd3fa71859f9f5d38f51de846e323d6 Modified Files -------------- src/interfaces/libpq/fe-connect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix libpq crashes on malformed target_session_attrs query result @ 2026-11-21 14:19 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Fujii Masao @ 2026-11-21 14:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix libpq crashes on malformed target_session_attrs query results Applications using libpq could crash during connection establishment when a server returned an unexpected result for an internal query used to check target_session_attrs. This happened because libpq checked that the result contained one row, but did not check the column count before reading the first column. A result with one row and no columns caused PQgetvalue() to return NULL, which was then passed to strncmp(). Fix this by requiring exactly one column in the results of SHOW transaction_read_only and SELECT pg_catalog.pg_is_in_recovery(). Malformed results now follow the existing error path, rejecting the connection attempt to that host and trying the next host, if any. Backpatch to all supported versions. Author: s1ko <s1ko@riseup.net> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/f1743511-5fab-482e-94ec-1198ce18723e@riseup.net Backpatch-through: 15 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/c2cd57f68cfe1ddc46aa33c5791322e217b4eae3 Modified Files -------------- src/interfaces/libpq/fe-connect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix libpq crashes on malformed target_session_attrs query result @ 2026-11-21 14:19 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Fujii Masao @ 2026-11-21 14:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix libpq crashes on malformed target_session_attrs query results Applications using libpq could crash during connection establishment when a server returned an unexpected result for an internal query used to check target_session_attrs. This happened because libpq checked that the result contained one row, but did not check the column count before reading the first column. A result with one row and no columns caused PQgetvalue() to return NULL, which was then passed to strncmp(). Fix this by requiring exactly one column in the results of SHOW transaction_read_only and SELECT pg_catalog.pg_is_in_recovery(). Malformed results now follow the existing error path, rejecting the connection attempt to that host and trying the next host, if any. Backpatch to all supported versions. Author: s1ko <s1ko@riseup.net> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/f1743511-5fab-482e-94ec-1198ce18723e@riseup.net Backpatch-through: 15 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/42fa657db316e033ca5b30a4ac0bf69835b70ab8 Modified Files -------------- src/interfaces/libpq/fe-connect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix libpq crashes on malformed target_session_attrs query result @ 2026-11-21 14:19 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Fujii Masao @ 2026-11-21 14:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix libpq crashes on malformed target_session_attrs query results Applications using libpq could crash during connection establishment when a server returned an unexpected result for an internal query used to check target_session_attrs. This happened because libpq checked that the result contained one row, but did not check the column count before reading the first column. A result with one row and no columns caused PQgetvalue() to return NULL, which was then passed to strncmp(). Fix this by requiring exactly one column in the results of SHOW transaction_read_only and SELECT pg_catalog.pg_is_in_recovery(). Malformed results now follow the existing error path, rejecting the connection attempt to that host and trying the next host, if any. Backpatch to all supported versions. Author: s1ko <s1ko@riseup.net> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/f1743511-5fab-482e-94ec-1198ce18723e@riseup.net Backpatch-through: 15 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d870a9480ccd0479d931967cabda44baba5b260b Modified Files -------------- src/interfaces/libpq/fe-connect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix libpq crashes on malformed target_session_attrs query result @ 2026-11-21 14:19 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Fujii Masao @ 2026-11-21 14:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix libpq crashes on malformed target_session_attrs query results Applications using libpq could crash during connection establishment when a server returned an unexpected result for an internal query used to check target_session_attrs. This happened because libpq checked that the result contained one row, but did not check the column count before reading the first column. A result with one row and no columns caused PQgetvalue() to return NULL, which was then passed to strncmp(). Fix this by requiring exactly one column in the results of SHOW transaction_read_only and SELECT pg_catalog.pg_is_in_recovery(). Malformed results now follow the existing error path, rejecting the connection attempt to that host and trying the next host, if any. Backpatch to all supported versions. Author: s1ko <s1ko@riseup.net> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/f1743511-5fab-482e-94ec-1198ce18723e@riseup.net Backpatch-through: 15 Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/de2d7b602b43245fc7fccf08b8f04a2cf8e72fca Modified Files -------------- src/interfaces/libpq/fe-connect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2026-11-21 14:19 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-21 14:19 pgsql: Fix libpq crashes on malformed target_session_attrs query result Fujii Masao <fujii@postgresql.org> 2026-11-21 14:19 pgsql: Fix libpq crashes on malformed target_session_attrs query result Fujii Masao <fujii@postgresql.org> 2026-11-21 14:19 pgsql: Fix libpq crashes on malformed target_session_attrs query result Fujii Masao <fujii@postgresql.org> 2026-11-21 14:19 pgsql: Fix libpq crashes on malformed target_session_attrs query result Fujii Masao <fujii@postgresql.org> 2026-11-21 14:19 pgsql: Fix libpq crashes on malformed target_session_attrs query result Fujii Masao <fujii@postgresql.org> 2026-11-21 14:19 pgsql: Fix libpq crashes on malformed target_session_attrs query result Fujii Masao <fujii@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox