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

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Robin Haberkorn <haberkorn@b1-systems.de>, Jim Jones <jim.jones@uni-muenster.de>, pgsql-bugs@lists.postgresql.org, maralist86@mail.ru
Date: 2025-07-08T13:36:37Z
Lists: pgsql-bugs
Michael Paquier <michael@paquier.xyz> writes:
> 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?

The comment in xml_errorHandler() argues

     * Legacy error handling mode.  err_occurred is never set, we just add the
     * message to err_buf.  This mode exists because the xml2 contrib module
     * uses our error-handling infrastructure, but we don't want to change its
     * behaviour since it's deprecated anyway.  This is also why we don't
     * distinguish between notices, warnings and errors here --- the old-style
     * generic error handler wouldn't have done that either.

So switching to _ALL (or even _WELL_FORMED) mode would result in
nontrivial differences in the behavior of xpath.c's functions with
bad input.  Maybe that's a reasonable thing to do, but it's a
question of user-visible behavior not just code cleanliness.

			regards, tom lane



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