]> git.ipfire.org Git - thirdparty/postgresql.git/commit
xml2: Fix crash with namespace nodes in xpath_nodeset()
authorMichael Paquier <michael@paquier.xyz>
Thu, 11 Jun 2026 05:29:18 +0000 (14:29 +0900)
committerMichael Paquier <michael@paquier.xyz>
Thu, 11 Jun 2026 05:29:18 +0000 (14:29 +0900)
commit9d33a5a804db48b254de7a0ad2fde03152f378e3
tree364f1a9780dcc4c1dcd9681d52c40f34e92d34eb
parent9d141466ff087230571e9c9dfd720deb94977253
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
contrib/xml2/expected/xml2.out
contrib/xml2/expected/xml2_1.out
contrib/xml2/sql/xml2.sql
contrib/xml2/xpath.c