agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: xml2: Fix crash with namespace nodes in xpath_nodeset()
Date: Thu, 11 Jun 2026 05:29:48 +0000
Message-ID: <E1wXXzA-001xcX-1F@gemulon.postgresql.org> (raw)

xml2: Fix crash with namespace nodes in xpath_nodeset()

pgxmlNodeSetToText() passed nodeTab[i]->doc to xmlNodeDump() without
checking the node type, which could cause a crash as a
XML_NAMESPACE_DECL maps to a xmlNs struct.  The passed-in code would
then be dereferenced in xmlNodeDump().

This commit switches the code to render XML_NAMESPACE_DECL nodes with
xmlXPathCastNodeToString(), like xpath_table().  Some tests are added,
written by me.

Author: Andrey Chernyy <andrey.cherny@tantorlabs.com>
Co-authored-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/20260611031436.5afde3cb@andrnote
Backpatch-through: 14

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9d33a5a804db48b254de7a0ad2fde03152f378e3

Modified Files
--------------
contrib/xml2/expected/xml2.out   |  8 ++++++++
contrib/xml2/expected/xml2_1.out |  8 ++++++++
contrib/xml2/sql/xml2.sql        |  3 +++
contrib/xml2/xpath.c             | 23 +++++++++++++++++++----
4 files changed, 38 insertions(+), 4 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1wXXzA-001xcX-1F@gemulon.postgresql.org>
Permalink:  ../E1wXXzA-001xcX-1F@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wXXzA-001xcX-1F@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: xml2: Fix crash with namespace nodes in xpath_nodeset()
  In-Reply-To: <E1wXXzA-001xcX-1F@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox