]> 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:28 +0000 (14:29 +0900)
committerMichael Paquier <michael@paquier.xyz>
Thu, 11 Jun 2026 05:29:28 +0000 (14:29 +0900)
commitbc5775149f59cc6d80c2a5ceb410bba473a12407
treef658b26ba6b024fa80ef9f728abcaf73f4cbf3e8
parenta7e0e42a226dc99f62987237d8356a7536f1890a
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