[xml] xmllib2-2.6.32 on x86_64



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)

Regards


--- libxml2-2.6.32/xmlreader.c.orig     2008-09-02 04:34:59.000000000 +0200
+++ libxml2-2.6.32/xmlreader.c  2008-09-02 04:39:01.000000000 +0200
@@ -44,6 +44,25 @@
 #include <libxml/pattern.h>
 #endif

+/*
+ * The following VA_COPY was coded following an example in
+ * the Samba project.  It may not be sufficient for some
+ * esoteric implementations of va_list (i.e. it may need
+ * something involving a memcpy) but (hopefully) will be
+ * sufficient for libxml2.
+ */
+#ifndef VA_COPY
+  #ifdef HAVE_VA_COPY
+    #define VA_COPY(dest, src) va_copy(dest, src)
+  #else
+    #ifdef HAVE___VA_COPY
+      #define VA_COPY(dest,src) __va_copy(dest, src)
+    #else
+      #define VA_COPY(dest,src) (dest) = (src)
+    #endif
+  #endif
+#endif
+
 /* #define DEBUG_CALLBACKS */
 /* #define DEBUG_READER */

@@ -4498,6 +4517,7 @@
     int chars;
     char *larger;
     char *str;
+    va_list aq;

     str = (char *) xmlMallocAtomic(150);
     if (str == NULL) {
@@ -4508,7 +4528,9 @@
     size = 150;

     while (1) {
-        chars = vsnprintf(str, size, msg, ap);
+       VA_COPY(aq, ap);
+        chars = vsnprintf(str, size, msg, aq);
+       va_end(aq);
         if ((chars > -1) && (chars < size))
             break;
         if (chars > -1)



-- 
Riccardo Scussat
DSPLABS Srl
dsplabs dsplabs net
PGP Key ID: 0x618E24FE




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]