pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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-003jQf-0j@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
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0b0041b942f7ecca56efec4cb882caec0247984f

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         |  9 ++++++++-
4 files changed, 30 insertions(+), 1 deletion(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1w0wcT-003jQf-0j@gemulon.postgresql.org>
Permalink:  ../E1w0wcT-003jQf-0j@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1w0wcT-003jQf-0j@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 failure with xslt_process() under -fsanitize=undefined
  In-Reply-To: <E1w0wcT-003jQf-0j@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