From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: xml2: Fix failure with xslt_process() under -fsanitize=undefined
Date: Fri, 13 Mar 2026 07:07:37 +0000
Message-ID: <E1w0wcT-003jQW-0R@gemulon.postgresql.org> (raw)
xml2: Fix failure with xslt_process() under -fsanitize=undefined
The logic of xslt_process() has never considered the fact that
xsltSaveResultToString() would return NULL for an empty string (the
upstream code has always done so, with a string length of 0). This
would cause memcpy() to be called with a NULL pointer, something
forbidden by POSIX.
Like 46ab07ffda9d and similar fixes, this is backpatched down to all the
supported branches, with a test case to cover this scenario. An empty
string has been always returned in xml2 in this case, based on the
history of the module, so this is an old issue.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/c516a0d9-4406-47e3-9087-5ca5176ebcf9@gmail.com
Backpatch-through: 14
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/7d64419f8073dafdb8ae28c20b1323bf6a93c55e
Modified Files
--------------
contrib/xml2/expected/xml2.out | 10 ++++++++++
contrib/xml2/expected/xml2_1.out | 6 ++++++
contrib/xml2/sql/xml2.sql | 6 ++++++
contrib/xml2/xslt_proc.c | 11 ++++++++++-
4 files changed, 32 insertions(+), 1 deletion(-)
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 failure with xslt_process() under -fsanitize=undefined
In-Reply-To: <E1w0wcT-003jQW-0R@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox