On Tue, Sep 02, 2008 at 10:02:20AM +0200, Daniel Veillard wrote:
> On Tue, Sep 02, 2008 at 04:50:29AM +0200, DspLabs Srl wrote:
> > Hello,
> >
> > the attached patch fixes xmllib2-2.6.32 for a segfault issue occurring
> > on Linux x86_64 systems during validation when an external error handler
> > is set with xmlTextReaderSetErrorHandler function.
> > The problem is located in file xmlreader.c, function
> > xmlTextReaderBuildMessage and is due to wrong usage of variable
> > arguments functions, clearly an invalid code (ISO C99, 7.15)
>
> Hum, I see what you mean, but instead I think just adding
> va_start(ap, msg); and va_end(ap); around the snprintf and limiting the
> loop to a maximum size limit is probably a better solution as it
> does exactly as the XML_GET_VAR_STR() macro does in error.c
> And that code got a lot of testing, so i would rather reuse
> the same rather than a va-list copy,
>
> what do you think ?
Can you try the enclosed patch on your example ?
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
[EMAIL PROTECTED] | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
Index: xmlreader.c
===================================================================
--- xmlreader.c (revision 3787)
+++ xmlreader.c (working copy)
@@ -4500,7 +4500,7 @@ xmlTextReaderStandalone(xmlTextReaderPtr
/* helper to build a xmlMalloc'ed string from a format and va_list */
static char *
xmlTextReaderBuildMessage(const char *msg, va_list ap) {
- int size;
+ int size, prev_size = -1;
int chars;
char *larger;
char *str;
@@ -4513,10 +4513,17 @@ xmlTextReaderBuildMessage(const char *ms
size = 150;
- while (1) {
+ while (size < 64000) {
+ va_start(ap, msg);
chars = vsnprintf(str, size, msg, ap);
- if ((chars > -1) && (chars < size))
- break;
+ va_end(ap);
+ if ((chars > -1) && (chars < size)) {
+ if (prev_size == chars) {
+ break;
+ } else {
+ prev_size = chars;
+ }
+ }
if (chars > -1)
size += chars + 1;
else
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml