Re: BUG #18943: Return value of a function 'xmlBufferCreate' is dereferenced at xpath.c:177 without checking for NUL

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Robin Haberkorn <haberkorn@b1-systems.de>
Cc: Jim Jones <jim.jones@uni-muenster.de>, Tom Lane <tgl@sss.pgh.pa.us>, pgsql-bugs@lists.postgresql.org, maralist86@mail.ru
Date: 2025-07-08T11:23:30Z
Lists: pgsql-bugs
On Tue, Jul 08, 2025 at 09:49:20AM +0000, Robin Haberkorn wrote:
> I know this has already been committed, but why are we still using
> PG_XML_STRICTNESS_LEGACY in xpath.c? As we are always checking
> pg_xml_error_occurred() this should no longer be necessary.

Are you sure that you can do that?  When I looked at this code I was
under the impression that xmlReadMemory() can generate an error and
can go through the error context we set, so the legacy mode counted
for xpath_string() at least.

Perhaps we should just remove the pg_xml_error_occurred() then if
that's confusing, keeping the legacy mode.  Or do you have a different
idea in mind?
--
Michael

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. xml2: Fix failure with xslt_process() under -fsanitize=undefined

  2. Fix misuse of "volatile" in xml.c

  3. xml2: Improve error handling of libxml2 calls

  4. Improve error handling of libxml2 calls in xml.c