Re: [REVIEW] Re: Fix xpath() to return namespace definitions - Mailing list pgsql-hackers

From Ali Akbar
Subject Re: [REVIEW] Re: Fix xpath() to return namespace definitions
Date
Msg-id CACQjQLqykR2M832uLFO1FnhrXpSzEvJ7f1JLrnXJJ_-Uw25dFQ@mail.gmail.com
Whole thread Raw
In response to Re: [REVIEW] Re: Fix xpath() to return namespace definitions  (Ali Akbar <the.apaan@gmail.com>)
List pgsql-hackers
Greetings,

Because of the memory bug in xmlCopyNode, this is a new patch with different method. In this patch, instead of using xmlCopyNode to bring the namespace back, we added the required namespaces to the  node before dumping the node to string, and cleaning it up afterwards (because the same node could be dumped again in next xpath result).

Thanks,
Ali Akbar


2014-07-11 15:36 GMT+07:00 Ali Akbar <the.apaan@gmail.com>:
Greetings,

Attached modified patch to handle xmlCopyNode returning NULL. The patch is larger because xmlerrcxt must be passed to xml_xmlnodetoxmltype (xmlerrcxt is needed for calling xml_ereport).

From libxml2 source, it turns out that the other cases that xmlCopyNode will return NULL will not happen. So in this patch i assume that the only case is memory exhaustion.

But i found some bug in libxml2's code, because we call xmlCopyNode with 1 as the second parameter, internally xmlCopyNode will call xmlStaticCopyNode recursively via xmlStaticCopyNodeList. And xmlStaticCopyNodeList doesn't check the return of xmlStaticCopyNode whether it's NULL. So if someday the recursion returns NULL (maybe because of memory exhaustion), it will SEGFAULT.

Knowing this but in libxml2 code, is this patch is still acceptable?

Thanks,
Ali Akbar



--
Ali Akbar
Attachment

pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Question about coding of free space map
Next
From: Michael Paquier
Date:
Subject: Misleading error message in logical decoding for binary plugins