xzyang / rpms / libxml2

Forked from rpms/libxml2 3 years ago
Clone

Blame SOURCES/libxml2-Fix-some-format-string-warnings-with-possible-format-string-vulnerability.patch

1c8959
From 671658873655a1bb1e478894c0c71f9c98968fff Mon Sep 17 00:00:00 2001
1c8959
From: David Kilzer <ddkilzer@webkit.org>
1c8959
Date: Fri, 13 May 2016 15:13:17 +0800
1c8959
Subject: [PATCH] Fix some format string warnings with possible format string
1c8959
 vulnerability
1c8959
To: libvir-list@redhat.com
1c8959
1c8959
For https://bugzilla.gnome.org/show_bug.cgi?id=761029
1c8959
1c8959
Decorate every method in libxml2 with the appropriate
1c8959
LIBXML_ATTR_FORMAT(fmt,args) macro and add some cleanups
1c8959
following the reports.
1c8959
1c8959
Signed-off-by: Daniel Veillard <veillard@redhat.com>
1c8959
---
1c8959
 HTMLparser.c                     |  4 +--
1c8959
 SAX2.c                           | 12 ++++----
1c8959
 catalog.c                        |  2 +-
1c8959
 configure.in                     |  4 +--
1c8959
 debugXML.c                       |  4 +--
1c8959
 encoding.c                       |  2 +-
1c8959
 entities.c                       |  2 +-
1c8959
 error.c                          |  2 +-
1c8959
 include/libxml/parserInternals.h |  2 +-
1c8959
 include/libxml/xmlerror.h        |  2 +-
1c8959
 include/libxml/xmlstring.h       |  8 ++---
1c8959
 libxml.h                         |  2 +-
1c8959
 parser.c                         | 37 +++++++++++-----------
1c8959
 parserInternals.c                |  4 +--
1c8959
 relaxng.c                        |  4 +--
1c8959
 schematron.c                     |  2 +-
1c8959
 testModule.c                     |  2 +-
1c8959
 valid.c                          |  8 ++---
1c8959
 xinclude.c                       |  4 +--
1c8959
 xmlIO.c                          | 14 ++++-----
1c8959
 xmllint.c                        | 20 ++++++------
1c8959
 xmlreader.c                      | 16 +++++++---
1c8959
 xmlschemas.c                     | 66 ++++++++++++++++++++--------------------
1c8959
 xmlstring.c                      |  4 +--
1c8959
 xmlwriter.c                      |  4 +--
1c8959
 xpath.c                          |  2 +-
1c8959
 xpointer.c                       |  2 +-
1c8959
 27 files changed, 121 insertions(+), 114 deletions(-)
1c8959
1c8959
diff --git a/HTMLparser.c b/HTMLparser.c
1c8959
index e7d802d..cd5ab05 100644
1c8959
--- a/HTMLparser.c
1c8959
+++ b/HTMLparser.c
1c8959
@@ -105,7 +105,7 @@ htmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
1c8959
  *
1c8959
  * Handle a fatal parser error, i.e. violating Well-Formedness constraints
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 htmlParseErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
              const char *msg, const xmlChar *str1, const xmlChar *str2)
1c8959
 {
1c8959
@@ -132,7 +132,7 @@ htmlParseErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a fatal parser error, i.e. violating Well-Formedness constraints
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 htmlParseErrInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
              const char *msg, int val)
1c8959
 {
1c8959
diff --git a/SAX2.c b/SAX2.c
1c8959
index 4adf202..d90f449 100644
1c8959
--- a/SAX2.c
1c8959
+++ b/SAX2.c
1c8959
@@ -55,7 +55,7 @@
1c8959
  * @ctxt:  an XML validation parser context
1c8959
  * @msg:   a string to accompany the error message
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(2,0)
1c8959
 xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) {
1c8959
     xmlStructuredErrorFunc schannel = NULL;
1c8959
     const char *str1 = "out of memory\n";
1c8959
@@ -93,7 +93,7 @@ xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) {
1c8959
  *
1c8959
  * Handle a validation error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlErrValid(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
             const char *msg, const char *str1, const char *str2)
1c8959
 {
1c8959
@@ -133,7 +133,7 @@ xmlErrValid(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a fatal parser error, i.e. violating Well-Formedness constraints
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
                const char *msg, const xmlChar *str1, const xmlChar *str2)
1c8959
 {
1c8959
@@ -164,7 +164,7 @@ xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a parser warning
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
                const char *msg, const xmlChar *str1)
1c8959
 {
1c8959
@@ -189,7 +189,7 @@ xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a namespace error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
             const char *msg, const xmlChar *str1, const xmlChar *str2)
1c8959
 {
1c8959
@@ -213,7 +213,7 @@ xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a namespace warning
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlNsWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
              const char *msg, const xmlChar *str1, const xmlChar *str2)
1c8959
 {
1c8959
diff --git a/catalog.c b/catalog.c
1c8959
index 8e34cd2..5c9f6de 100644
1c8959
--- a/catalog.c
1c8959
+++ b/catalog.c
1c8959
@@ -238,7 +238,7 @@ xmlCatalogErrMemory(const char *extra)
1c8959
  *
1c8959
  * Handle a catalog error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(4,0)
1c8959
 xmlCatalogErr(xmlCatalogEntryPtr catal, xmlNodePtr node, int error,
1c8959
                const char *msg, const xmlChar *str1, const xmlChar *str2,
1c8959
 	       const xmlChar *str3)
1c8959
diff --git a/configure.in b/configure.in
1c8959
index d449b11..1dee5ba 100644
1c8959
--- a/configure.in
1c8959
+++ b/configure.in
1c8959
@@ -705,7 +705,7 @@ else
1c8959
     fi
1c8959
 
1c8959
     # warnings we'd like to see
1c8959
-    CFLAGS="${CFLAGS} -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls"
1c8959
+    CFLAGS="${CFLAGS} -pedantic -W -Wformat -Wno-format-extra-args -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls"
1c8959
     # warnings we'd like to supress
1c8959
     CFLAGS="${CFLAGS} -Wno-long-long"
1c8959
     case "${host}" in
1c8959
@@ -920,7 +920,7 @@ if [[ "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/XML" ]] || \
1c8959
 	fi
1c8959
     fi
1c8959
     if test "${GCC}" = "yes" ; then
1c8959
-    CFLAGS="-g -O -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wall"
1c8959
+    CFLAGS="-g -O -pedantic -W -Wformat -Wno-format-extra-args -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wall"
1c8959
     fi
1c8959
     STATIC_BINARIES="-static"
1c8959
 dnl -Wcast-qual -ansi
1c8959
diff --git a/debugXML.c b/debugXML.c
1c8959
index c8efe6a..b6e7b2f 100644
1c8959
--- a/debugXML.c
1c8959
+++ b/debugXML.c
1c8959
@@ -164,7 +164,7 @@ xmlDebugErr(xmlDebugCtxtPtr ctxt, int error, const char *msg)
1c8959
 		    NULL, NULL, NULL, 0, 0,
1c8959
 		    "%s", msg);
1c8959
 }
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlDebugErr2(xmlDebugCtxtPtr ctxt, int error, const char *msg, int extra)
1c8959
 {
1c8959
     ctxt->errors++;
1c8959
@@ -174,7 +174,7 @@ xmlDebugErr2(xmlDebugCtxtPtr ctxt, int error, const char *msg, int extra)
1c8959
 		    NULL, NULL, NULL, 0, 0,
1c8959
 		    msg, extra);
1c8959
 }
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlDebugErr3(xmlDebugCtxtPtr ctxt, int error, const char *msg, const char *extra)
1c8959
 {
1c8959
     ctxt->errors++;
1c8959
diff --git a/encoding.c b/encoding.c
1c8959
index 7330e90..dd62b3a 100644
1c8959
--- a/encoding.c
1c8959
+++ b/encoding.c
1c8959
@@ -93,7 +93,7 @@ xmlEncodingErrMemory(const char *extra)
1c8959
  *
1c8959
  * n encoding error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(2,0)
1c8959
 xmlEncodingErr(xmlParserErrors error, const char *msg, const char *val)
1c8959
 {
1c8959
     __xmlRaiseError(NULL, NULL, NULL, NULL, NULL,
1c8959
diff --git a/entities.c b/entities.c
1c8959
index 0c484a7..f330959 100644
1c8959
--- a/entities.c
1c8959
+++ b/entities.c
1c8959
@@ -83,7 +83,7 @@ xmlEntitiesErrMemory(const char *extra)
1c8959
  *
1c8959
  * Handle an out of memory condition
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(2,0)
1c8959
 xmlEntitiesErr(xmlParserErrors code, const char *msg)
1c8959
 {
1c8959
     __xmlSimpleError(XML_FROM_TREE, code, NULL, msg, NULL);
1c8959
diff --git a/error.c b/error.c
1c8959
index 9c45040..2e8dfce 100644
1c8959
--- a/error.c
1c8959
+++ b/error.c
1c8959
@@ -18,7 +18,7 @@
1c8959
 
1c8959
 void XMLCDECL xmlGenericErrorDefaultFunc	(void *ctx ATTRIBUTE_UNUSED,
1c8959
 				 const char *msg,
1c8959
-				 ...);
1c8959
+				 ...) LIBXML_ATTR_FORMAT(2,3);
1c8959
 
1c8959
 #define XML_GET_VAR_STR(msg, str) {				\
1c8959
     int       size, prev_size = -1;				\
1c8959
diff --git a/include/libxml/parserInternals.h b/include/libxml/parserInternals.h
1c8959
index 6065320..f30fc68 100644
1c8959
--- a/include/libxml/parserInternals.h
1c8959
+++ b/include/libxml/parserInternals.h
1c8959
@@ -351,7 +351,7 @@ XMLPUBFUN void XMLCALL
1c8959
 						 xmlParserErrors xmlerr,
1c8959
 						 const char *msg,
1c8959
 						 const xmlChar * str1,
1c8959
-						 const xmlChar * str2);
1c8959
+						 const xmlChar * str2) LIBXML_ATTR_FORMAT(3,0);
1c8959
 #endif
1c8959
 
1c8959
 /**
1c8959
diff --git a/include/libxml/xmlerror.h b/include/libxml/xmlerror.h
1c8959
index 537a396..acd2cd7 100644
1c8959
--- a/include/libxml/xmlerror.h
1c8959
+++ b/include/libxml/xmlerror.h
1c8959
@@ -937,7 +937,7 @@ XMLPUBFUN void XMLCALL
1c8959
 				 int code,
1c8959
 				 xmlNodePtr node,
1c8959
 				 const char *msg,
1c8959
-				 const char *extra);
1c8959
+				 const char *extra) LIBXML_ATTR_FORMAT(4,0);
1c8959
 #endif
1c8959
 #ifdef __cplusplus
1c8959
 }
1c8959
diff --git a/include/libxml/xmlstring.h b/include/libxml/xmlstring.h
1c8959
index 2036236..2d0b2d1 100644
1c8959
--- a/include/libxml/xmlstring.h
1c8959
+++ b/include/libxml/xmlstring.h
1c8959
@@ -97,13 +97,13 @@ XMLPUBFUN xmlChar * XMLCALL
1c8959
 XMLPUBFUN int XMLCALL
1c8959
                 xmlStrPrintf             (xmlChar *buf,
1c8959
                                          int len,
1c8959
-                                         const xmlChar *msg,
1c8959
-                                         ...);
1c8959
+                                         const char *msg,
1c8959
+                                         ...) LIBXML_ATTR_FORMAT(3,4);
1c8959
 XMLPUBFUN int XMLCALL
1c8959
                 xmlStrVPrintf                (xmlChar *buf,
1c8959
                                          int len,
1c8959
-                                         const xmlChar *msg,
1c8959
-                                         va_list ap);
1c8959
+                                         const char *msg,
1c8959
+                                         va_list ap) LIBXML_ATTR_FORMAT(3,0);
1c8959
 
1c8959
 XMLPUBFUN int XMLCALL
1c8959
         xmlGetUTF8Char                   (const unsigned char *utf,
1c8959
diff --git a/libxml.h b/libxml.h
1c8959
index 2da9044..4558b70 100644
1c8959
--- a/libxml.h
1c8959
+++ b/libxml.h
1c8959
@@ -68,7 +68,7 @@ extern int __xmlRegisterCallbacks;
1c8959
  * internal error reporting routines, shared but not partof the API.
1c8959
  */
1c8959
 void __xmlIOErr(int domain, int code, const char *extra);
1c8959
-void __xmlLoaderErr(void *ctx, const char *msg, const char *filename);
1c8959
+void __xmlLoaderErr(void *ctx, const char *msg, const char *filename) LIBXML_ATTR_FORMAT(2,0);
1c8959
 #ifdef LIBXML_HTML_ENABLED
1c8959
 /*
1c8959
  * internal function of HTML parser needed for xmlParseInNodeContext
1c8959
diff --git a/parser.c b/parser.c
1c8959
index 2ae44c5..7413596 100644
1c8959
--- a/parser.c
1c8959
+++ b/parser.c
1c8959
@@ -350,7 +350,6 @@ static void
1c8959
 xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
1c8959
 {
1c8959
     const char *errmsg;
1c8959
-    char errstr[129] = "";
1c8959
 
1c8959
     if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
1c8959
         (ctxt->instate == XML_PARSER_EOF))
1c8959
@@ -537,15 +536,17 @@ xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
1c8959
         default:
1c8959
             errmsg = "Unregistered error message";
1c8959
     }
1c8959
-    if (info == NULL)
1c8959
-        snprintf(errstr, 128, "%s\n", errmsg);
1c8959
-    else
1c8959
-        snprintf(errstr, 128, "%s: %%s\n", errmsg);
1c8959
     if (ctxt != NULL)
1c8959
 	ctxt->errNo = error;
1c8959
-    __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
1c8959
-                    XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, &errstr[0],
1c8959
-                    info);
1c8959
+    if (info == NULL) {
1c8959
+        __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
1c8959
+                        XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s\n",
1c8959
+                        errmsg);
1c8959
+    } else {
1c8959
+        __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
1c8959
+                        XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s: %s\n",
1c8959
+                        errmsg, info);
1c8959
+    }
1c8959
     if (ctxt != NULL) {
1c8959
 	ctxt->wellFormed = 0;
1c8959
 	if (ctxt->recovery == 0)
1c8959
@@ -561,7 +562,7 @@ xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
1c8959
  *
1c8959
  * Handle a fatal parser error, i.e. violating Well-Formedness constraints
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
                const char *msg)
1c8959
 {
1c8959
@@ -589,7 +590,7 @@ xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a warning.
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
               const char *msg, const xmlChar *str1, const xmlChar *str2)
1c8959
 {
1c8959
@@ -627,7 +628,7 @@ xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a validity error.
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
               const char *msg, const xmlChar *str1, const xmlChar *str2)
1c8959
 {
1c8959
@@ -667,7 +668,7 @@ xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a fatal parser error, i.e. violating Well-Formedness constraints
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlFatalErrMsgInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
                   const char *msg, int val)
1c8959
 {
1c8959
@@ -697,7 +698,7 @@ xmlFatalErrMsgInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a fatal parser error, i.e. violating Well-Formedness constraints
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlFatalErrMsgStrIntStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
                   const char *msg, const xmlChar *str1, int val,
1c8959
 		  const xmlChar *str2)
1c8959
@@ -727,7 +728,7 @@ xmlFatalErrMsgStrIntStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a fatal parser error, i.e. violating Well-Formedness constraints
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
                   const char *msg, const xmlChar * val)
1c8959
 {
1c8959
@@ -756,7 +757,7 @@ xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a non fatal parser error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
                   const char *msg, const xmlChar * val)
1c8959
 {
1c8959
@@ -781,7 +782,7 @@ xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a fatal parser error, i.e. violating Well-Formedness constraints
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
          const char *msg,
1c8959
          const xmlChar * info1, const xmlChar * info2,
1c8959
@@ -810,7 +811,7 @@ xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a namespace warning error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlNsWarn(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
          const char *msg,
1c8959
          const xmlChar * info1, const xmlChar * info2,
1c8959
@@ -5510,7 +5511,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
1c8959
 	    skipped = SKIP_BLANKS;
1c8959
 	    if (skipped == 0) {
1c8959
 		xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
1c8959
-			       "Space required after '%'\n");
1c8959
+			       "Space required after '%%'\n");
1c8959
 	    }
1c8959
 	    isParameter = 1;
1c8959
 	}
1c8959
diff --git a/parserInternals.c b/parserInternals.c
1c8959
index 341d6a1..aac6420 100644
1c8959
--- a/parserInternals.c
1c8959
+++ b/parserInternals.c
1c8959
@@ -169,7 +169,7 @@ __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr,
1c8959
  *
1c8959
  * Handle an internal error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(2,0)
1c8959
 xmlErrInternal(xmlParserCtxtPtr ctxt, const char *msg, const xmlChar * str)
1c8959
 {
1c8959
     if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
1c8959
@@ -197,7 +197,7 @@ xmlErrInternal(xmlParserCtxtPtr ctxt, const char *msg, const xmlChar * str)
1c8959
  *
1c8959
  * n encoding error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlErrEncodingInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
1c8959
                   const char *msg, int val)
1c8959
 {
1c8959
diff --git a/relaxng.c b/relaxng.c
1c8959
index 370e314..b531081 100644
1c8959
--- a/relaxng.c
1c8959
+++ b/relaxng.c
1c8959
@@ -507,7 +507,7 @@ xmlRngVErrMemory(xmlRelaxNGValidCtxtPtr ctxt, const char *extra)
1c8959
  *
1c8959
  * Handle a Relax NG Parsing error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(4,0)
1c8959
 xmlRngPErr(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node, int error,
1c8959
            const char *msg, const xmlChar * str1, const xmlChar * str2)
1c8959
 {
1c8959
@@ -541,7 +541,7 @@ xmlRngPErr(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node, int error,
1c8959
  *
1c8959
  * Handle a Relax NG Validation error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(4,0)
1c8959
 xmlRngVErr(xmlRelaxNGValidCtxtPtr ctxt, xmlNodePtr node, int error,
1c8959
            const char *msg, const xmlChar * str1, const xmlChar * str2)
1c8959
 {
1c8959
diff --git a/schematron.c b/schematron.c
1c8959
index 537b868..6f80c5c 100644
1c8959
--- a/schematron.c
1c8959
+++ b/schematron.c
1c8959
@@ -243,7 +243,7 @@ xmlSchematronPErrMemory(xmlSchematronParserCtxtPtr ctxt,
1c8959
  *
1c8959
  * Handle a parser error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(4,0)
1c8959
 xmlSchematronPErr(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr node, int error,
1c8959
               const char *msg, const xmlChar * str1, const xmlChar * str2)
1c8959
 {
1c8959
diff --git a/testModule.c b/testModule.c
1c8959
index e399f5c..77b7ba1 100644
1c8959
--- a/testModule.c
1c8959
+++ b/testModule.c
1c8959
@@ -47,7 +47,7 @@ int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
1c8959
 
1c8959
     /* build the module filename, and confirm the module exists */
1c8959
     xmlStrPrintf(filename, sizeof(filename),
1c8959
-                 (const xmlChar*) "%s/testdso%s",
1c8959
+                 "%s/testdso%s",
1c8959
                  (const xmlChar*)MODULE_PATH,
1c8959
 		 (const xmlChar*)LIBXML_MODULE_EXTENSION);
1c8959
 
1c8959
diff --git a/valid.c b/valid.c
1c8959
index 6e53a76..657e3c8 100644
1c8959
--- a/valid.c
1c8959
+++ b/valid.c
1c8959
@@ -93,7 +93,7 @@ xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
1c8959
  *
1c8959
  * Handle a validation error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlErrValid(xmlValidCtxtPtr ctxt, xmlParserErrors error,
1c8959
             const char *msg, const char *extra)
1c8959
 {
1c8959
@@ -137,7 +137,7 @@ xmlErrValid(xmlValidCtxtPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a validation error, provide contextual informations
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(4,0)
1c8959
 xmlErrValidNode(xmlValidCtxtPtr ctxt,
1c8959
                 xmlNodePtr node, xmlParserErrors error,
1c8959
                 const char *msg, const xmlChar * str1,
1c8959
@@ -180,7 +180,7 @@ xmlErrValidNode(xmlValidCtxtPtr ctxt,
1c8959
  *
1c8959
  * Handle a validation error, provide contextual informations
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(4,0)
1c8959
 xmlErrValidNodeNr(xmlValidCtxtPtr ctxt,
1c8959
                 xmlNodePtr node, xmlParserErrors error,
1c8959
                 const char *msg, const xmlChar * str1,
1c8959
@@ -221,7 +221,7 @@ xmlErrValidNodeNr(xmlValidCtxtPtr ctxt,
1c8959
  *
1c8959
  * Handle a validation error, provide contextual information
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(4,0)
1c8959
 xmlErrValidWarning(xmlValidCtxtPtr ctxt,
1c8959
                 xmlNodePtr node, xmlParserErrors error,
1c8959
                 const char *msg, const xmlChar * str1,
1c8959
diff --git a/xinclude.c b/xinclude.c
1c8959
index ace005b..f56c7c4 100644
1c8959
--- a/xinclude.c
1c8959
+++ b/xinclude.c
1c8959
@@ -124,7 +124,7 @@ xmlXIncludeErrMemory(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node,
1c8959
  *
1c8959
  * Handle an XInclude error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(4,0)
1c8959
 xmlXIncludeErr(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, int error,
1c8959
                const char *msg, const xmlChar *extra)
1c8959
 {
1c8959
@@ -146,7 +146,7 @@ xmlXIncludeErr(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, int error,
1c8959
  *
1c8959
  * Emit an XInclude warning.
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(4,0)
1c8959
 xmlXIncludeWarn(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, int error,
1c8959
                const char *msg, const xmlChar *extra)
1c8959
 {
1c8959
diff --git a/xmlIO.c b/xmlIO.c
1c8959
index fc4e111..90a93e3 100644
1c8959
--- a/xmlIO.c
1c8959
+++ b/xmlIO.c
1c8959
@@ -1590,7 +1590,7 @@ xmlCreateZMemBuff( int compression ) {
1c8959
 	xmlFreeZMemBuff( buff );
1c8959
 	buff = NULL;
1c8959
 	xmlStrPrintf(msg, 500,
1c8959
-		    (const xmlChar *) "xmlCreateZMemBuff:  %s %d\n",
1c8959
+		    "xmlCreateZMemBuff:  %s %d\n",
1c8959
 		    "Error initializing compression context.  ZLIB error:",
1c8959
 		    z_err );
1c8959
 	xmlIOErr(XML_IO_WRITE, (const char *) msg);
1c8959
@@ -1658,7 +1658,7 @@ xmlZMemBuffExtend( xmlZMemBuffPtr buff, size_t ext_amt ) {
1c8959
     else {
1c8959
 	xmlChar msg[500];
1c8959
 	xmlStrPrintf(msg, 500,
1c8959
-		    (const xmlChar *) "xmlZMemBuffExtend:  %s %lu bytes.\n",
1c8959
+		    "xmlZMemBuffExtend:  %s %lu bytes.\n",
1c8959
 		    "Allocation failure extending output buffer to",
1c8959
 		    new_size );
1c8959
 	xmlIOErr(XML_IO_WRITE, (const char *) msg);
1c8959
@@ -1704,7 +1704,7 @@ xmlZMemBuffAppend( xmlZMemBuffPtr buff, const char * src, int len ) {
1c8959
 	if ( z_err != Z_OK ) {
1c8959
 	    xmlChar msg[500];
1c8959
 	    xmlStrPrintf(msg, 500,
1c8959
-			(const xmlChar *) "xmlZMemBuffAppend:  %s %d %s - %d",
1c8959
+			"xmlZMemBuffAppend:  %s %d %s - %d",
1c8959
 			"Compression error while appending",
1c8959
 			len, "bytes to buffer.  ZLIB error", z_err );
1c8959
 	    xmlIOErr(XML_IO_WRITE, (const char *) msg);
1c8959
@@ -1777,7 +1777,7 @@ xmlZMemBuffGetContent( xmlZMemBuffPtr buff, char ** data_ref ) {
1c8959
     else {
1c8959
 	xmlChar msg[500];
1c8959
 	xmlStrPrintf(msg, 500,
1c8959
-		    (const xmlChar *) "xmlZMemBuffGetContent:  %s - %d\n",
1c8959
+		    "xmlZMemBuffGetContent:  %s - %d\n",
1c8959
 		    "Error flushing zlib buffers.  Error code", z_err );
1c8959
 	xmlIOErr(XML_IO_WRITE, (const char *) msg);
1c8959
     }
1c8959
@@ -1982,7 +1982,7 @@ xmlIOHTTPWrite( void * context, const char * buffer, int len ) {
1c8959
 	if ( len < 0 ) {
1c8959
 	    xmlChar msg[500];
1c8959
 	    xmlStrPrintf(msg, 500,
1c8959
-			(const xmlChar *) "xmlIOHTTPWrite:  %s\n%s '%s'.\n",
1c8959
+			"xmlIOHTTPWrite:  %s\n%s '%s'.\n",
1c8959
 			"Error appending to internal buffer.",
1c8959
 			"Error sending document to URI",
1c8959
 			ctxt->uri );
1c8959
@@ -2054,7 +2054,7 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) {
1c8959
     if ( http_content == NULL ) {
1c8959
 	xmlChar msg[500];
1c8959
 	xmlStrPrintf(msg, 500,
1c8959
-		     (const xmlChar *) "xmlIOHTTPCloseWrite:  %s '%s' %s '%s'.\n",
1c8959
+		     "xmlIOHTTPCloseWrite:  %s '%s' %s '%s'.\n",
1c8959
 		     "Error retrieving content.\nUnable to",
1c8959
 		     http_mthd, "data to URI", ctxt->uri );
1c8959
 	xmlIOErr(XML_IO_WRITE, (const char *) msg);
1c8959
@@ -2126,7 +2126,7 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) {
1c8959
 	    else {
1c8959
                 xmlChar msg[500];
1c8959
                 xmlStrPrintf(msg, 500,
1c8959
-    (const xmlChar *) "xmlIOHTTPCloseWrite: HTTP '%s' of %d %s\n'%s' %s %d\n",
1c8959
+                      "xmlIOHTTPCloseWrite: HTTP '%s' of %d %s\n'%s' %s %d\n",
1c8959
 			    http_mthd, content_lgth,
1c8959
 			    "bytes to URI", ctxt->uri,
1c8959
 			    "failed.  HTTP return code:", http_rtn );
1c8959
diff --git a/xmllint.c b/xmllint.c
1c8959
index 26d8db1..85552cf 100644
1c8959
--- a/xmllint.c
1c8959
+++ b/xmllint.c
1c8959
@@ -449,7 +449,7 @@ startTimer(void)
1c8959
  *           message about the timing performed; format is a printf
1c8959
  *           type argument
1c8959
  */
1c8959
-static void XMLCDECL
1c8959
+static void XMLCDECL LIBXML_ATTR_FORMAT(1,2)
1c8959
 endTimer(const char *fmt, ...)
1c8959
 {
1c8959
     long msec;
1c8959
@@ -485,7 +485,7 @@ startTimer(void)
1c8959
 {
1c8959
     begin = clock();
1c8959
 }
1c8959
-static void XMLCDECL
1c8959
+static void XMLCDECL LIBXML_ATTR_FORMAT(1,2)
1c8959
 endTimer(const char *fmt, ...)
1c8959
 {
1c8959
     long msec;
1c8959
@@ -514,7 +514,7 @@ startTimer(void)
1c8959
      * Do nothing
1c8959
      */
1c8959
 }
1c8959
-static void XMLCDECL
1c8959
+static void XMLCDECL LIBXML_ATTR_FORMAT(1,2)
1c8959
 endTimer(char *format, ...)
1c8959
 {
1c8959
     /*
1c8959
@@ -634,7 +634,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) {
1c8959
  * Display and format an error messages, gives file, line, position and
1c8959
  * extra parameters.
1c8959
  */
1c8959
-static void XMLCDECL
1c8959
+static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
1c8959
 xmlHTMLError(void *ctx, const char *msg, ...)
1c8959
 {
1c8959
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
1c8959
@@ -671,7 +671,7 @@ xmlHTMLError(void *ctx, const char *msg, ...)
1c8959
  * Display and format a warning messages, gives file, line, position and
1c8959
  * extra parameters.
1c8959
  */
1c8959
-static void XMLCDECL
1c8959
+static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
1c8959
 xmlHTMLWarning(void *ctx, const char *msg, ...)
1c8959
 {
1c8959
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
1c8959
@@ -709,7 +709,7 @@ xmlHTMLWarning(void *ctx, const char *msg, ...)
1c8959
  * Display and format an validity error messages, gives file,
1c8959
  * line, position and extra parameters.
1c8959
  */
1c8959
-static void XMLCDECL
1c8959
+static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
1c8959
 xmlHTMLValidityError(void *ctx, const char *msg, ...)
1c8959
 {
1c8959
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
1c8959
@@ -746,7 +746,7 @@ xmlHTMLValidityError(void *ctx, const char *msg, ...)
1c8959
  * Display and format a validity warning messages, gives file, line,
1c8959
  * position and extra parameters.
1c8959
  */
1c8959
-static void XMLCDECL
1c8959
+static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
1c8959
 xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
1c8959
 {
1c8959
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
1c8959
@@ -1410,7 +1410,7 @@ commentDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value)
1c8959
  * Display and format a warning messages, gives file, line, position and
1c8959
  * extra parameters.
1c8959
  */
1c8959
-static void XMLCDECL
1c8959
+static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
1c8959
 warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
1c8959
 {
1c8959
     va_list args;
1c8959
@@ -1433,7 +1433,7 @@ warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
1c8959
  * Display and format a error messages, gives file, line, position and
1c8959
  * extra parameters.
1c8959
  */
1c8959
-static void XMLCDECL
1c8959
+static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
1c8959
 errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
1c8959
 {
1c8959
     va_list args;
1c8959
@@ -1456,7 +1456,7 @@ errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
1c8959
  * Display and format a fatalError messages, gives file, line, position and
1c8959
  * extra parameters.
1c8959
  */
1c8959
-static void XMLCDECL
1c8959
+static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
1c8959
 fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
1c8959
 {
1c8959
     va_list args;
1c8959
diff --git a/xmlreader.c b/xmlreader.c
1c8959
index 4fabaa9..d72129b 100644
1c8959
--- a/xmlreader.c
1c8959
+++ b/xmlreader.c
1c8959
@@ -4036,13 +4036,19 @@ xmlTextReaderCurrentDoc(xmlTextReaderPtr reader) {
1c8959
 }
1c8959
 
1c8959
 #ifdef LIBXML_SCHEMAS_ENABLED
1c8959
-static char *xmlTextReaderBuildMessage(const char *msg, va_list ap);
1c8959
+static char *xmlTextReaderBuildMessage(const char *msg, va_list ap) LIBXML_ATTR_FORMAT(1,0);
1c8959
 
1c8959
 static void XMLCDECL
1c8959
-xmlTextReaderValidityError(void *ctxt, const char *msg, ...);
1c8959
+xmlTextReaderValidityError(void *ctxt, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
1c8959
 
1c8959
 static void XMLCDECL
1c8959
-xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...);
1c8959
+xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
1c8959
+
1c8959
+static void XMLCDECL
1c8959
+xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
1c8959
+
1c8959
+static void XMLCDECL
1c8959
+xmlTextReaderValidityWarningRelay(void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
1c8959
 
1c8959
 static void XMLCDECL
1c8959
 xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...)
1c8959
@@ -4836,7 +4842,7 @@ xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error)
1c8959
     }
1c8959
 }
1c8959
 
1c8959
-static void XMLCDECL
1c8959
+static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
1c8959
 xmlTextReaderError(void *ctxt, const char *msg, ...)
1c8959
 {
1c8959
     va_list ap;
1c8959
@@ -4849,7 +4855,7 @@ xmlTextReaderError(void *ctxt, const char *msg, ...)
1c8959
 
1c8959
 }
1c8959
 
1c8959
-static void XMLCDECL
1c8959
+static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
1c8959
 xmlTextReaderWarning(void *ctxt, const char *msg, ...)
1c8959
 {
1c8959
     va_list ap;
1c8959
diff --git a/xmlschemas.c b/xmlschemas.c
1c8959
index 121533f..398cdd8 100644
1c8959
--- a/xmlschemas.c
1c8959
+++ b/xmlschemas.c
1c8959
@@ -1085,7 +1085,7 @@ xmlSchemaGetUnionSimpleTypeMemberTypes(xmlSchemaTypePtr type);
1c8959
 static void
1c8959
 xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 		     const char *funcName,
1c8959
-		     const char *message);
1c8959
+		     const char *message) LIBXML_ATTR_FORMAT(3,0);
1c8959
 static int
1c8959
 xmlSchemaCheckCOSSTDerivedOK(xmlSchemaAbstractCtxtPtr ctxt,
1c8959
 			     xmlSchemaTypePtr type,
1c8959
@@ -1889,7 +1889,7 @@ xmlSchemaPErrMemory(xmlSchemaParserCtxtPtr ctxt,
1c8959
  *
1c8959
  * Handle a parser error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(4,0)
1c8959
 xmlSchemaPErr(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error,
1c8959
               const char *msg, const xmlChar * str1, const xmlChar * str2)
1c8959
 {
1c8959
@@ -1922,7 +1922,7 @@ xmlSchemaPErr(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error,
1c8959
  *
1c8959
  * Handle a parser error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(5,0)
1c8959
 xmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
1c8959
                xmlNodePtr child, int error,
1c8959
                const char *msg, const xmlChar * str1, const xmlChar * str2)
1c8959
@@ -1951,7 +1951,7 @@ xmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
1c8959
  *
1c8959
  * Handle a parser error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(7,0)
1c8959
 xmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error,
1c8959
 		const xmlChar * strData1, const xmlChar * strData2,
1c8959
 		const xmlChar * strData3, const char *msg, const xmlChar * str1,
1c8959
@@ -2002,7 +2002,7 @@ xmlSchemaVErrMemory(xmlSchemaValidCtxtPtr ctxt,
1c8959
                      extra);
1c8959
 }
1c8959
 
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(2,0)
1c8959
 xmlSchemaPSimpleInternalErr(xmlNodePtr node,
1c8959
 			    const char *msg, const xmlChar *str)
1c8959
 {
1c8959
@@ -2013,18 +2013,21 @@ xmlSchemaPSimpleInternalErr(xmlNodePtr node,
1c8959
 #define WXS_ERROR_TYPE_ERROR 1
1c8959
 #define WXS_ERROR_TYPE_WARNING 2
1c8959
 /**
1c8959
- * xmlSchemaErr3:
1c8959
+ * xmlSchemaErr4Line:
1c8959
  * @ctxt: the validation context
1c8959
- * @node: the context node
1c8959
+ * @errorLevel: the error level
1c8959
  * @error: the error code
1c8959
+ * @node: the context node
1c8959
+ * @line: the line number
1c8959
  * @msg: the error message
1c8959
  * @str1: extra data
1c8959
  * @str2: extra data
1c8959
  * @str3: extra data
1c8959
+ * @str4: extra data
1c8959
  *
1c8959
  * Handle a validation error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(6,0)
1c8959
 xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
1c8959
 		  xmlErrorLevel errorLevel,
1c8959
 		  int error, xmlNodePtr node, int line, const char *msg,
1c8959
@@ -2137,7 +2140,7 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
1c8959
  *
1c8959
  * Handle a validation error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(4,0)
1c8959
 xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 	      int error, xmlNodePtr node, const char *msg,
1c8959
 	      const xmlChar *str1, const xmlChar *str2, const xmlChar *str3)
1c8959
@@ -2146,7 +2149,7 @@ xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 	msg, str1, str2, str3, NULL);
1c8959
 }
1c8959
 
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(4,0)
1c8959
 xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 	      int error, xmlNodePtr node, const char *msg,
1c8959
 	      const xmlChar *str1, const xmlChar *str2,
1c8959
@@ -2156,7 +2159,7 @@ xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 	msg, str1, str2, str3, str4);
1c8959
 }
1c8959
 
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(4,0)
1c8959
 xmlSchemaErr(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 	     int error, xmlNodePtr node, const char *msg,
1c8959
 	     const xmlChar *str1, const xmlChar *str2)
1c8959
@@ -2179,7 +2182,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg,
1c8959
 	/*
1c8959
 	* Don't try to format other nodes than element and
1c8959
 	* attribute nodes.
1c8959
-	* Play save and return an empty string.
1c8959
+	* Play safe and return an empty string.
1c8959
 	*/
1c8959
 	*msg = xmlStrdup(BAD_CAST "");
1c8959
 	return(*msg);
1c8959
@@ -2260,7 +2263,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg,
1c8959
     return (*msg);
1c8959
 }
1c8959
 
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlSchemaInternalErr2(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 		     const char *funcName,
1c8959
 		     const char *message,
1c8959
@@ -2271,24 +2274,21 @@ xmlSchemaInternalErr2(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 
1c8959
     if (actxt == NULL)
1c8959
         return;
1c8959
-    msg = xmlStrdup(BAD_CAST "Internal error: ");
1c8959
-    msg = xmlStrcat(msg, BAD_CAST funcName);
1c8959
-    msg = xmlStrcat(msg, BAD_CAST ", ");
1c8959
+    msg = xmlStrdup(BAD_CAST "Internal error: %s, ");
1c8959
     msg = xmlStrcat(msg, BAD_CAST message);
1c8959
     msg = xmlStrcat(msg, BAD_CAST ".\n");
1c8959
 
1c8959
     if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR)
1c8959
-	xmlSchemaErr(actxt, XML_SCHEMAV_INTERNAL, NULL,
1c8959
-	    (const char *) msg, str1, str2);
1c8959
-
1c8959
+	xmlSchemaErr3(actxt, XML_SCHEMAV_INTERNAL, NULL,
1c8959
+	    (const char *) msg, (const xmlChar *) funcName, str1, str2);
1c8959
     else if (actxt->type == XML_SCHEMA_CTXT_PARSER)
1c8959
-	xmlSchemaErr(actxt, XML_SCHEMAP_INTERNAL, NULL,
1c8959
-	    (const char *) msg, str1, str2);
1c8959
+	xmlSchemaErr3(actxt, XML_SCHEMAP_INTERNAL, NULL,
1c8959
+	    (const char *) msg, (const xmlChar *) funcName, str1, str2);
1c8959
 
1c8959
     FREE_AND_NULL(msg)
1c8959
 }
1c8959
 
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 		     const char *funcName,
1c8959
 		     const char *message)
1c8959
@@ -2297,7 +2297,7 @@ xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 }
1c8959
 
1c8959
 #if 0
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlSchemaPInternalErr(xmlSchemaParserCtxtPtr pctxt,
1c8959
 		     const char *funcName,
1c8959
 		     const char *message,
1c8959
@@ -2309,7 +2309,7 @@ xmlSchemaPInternalErr(xmlSchemaParserCtxtPtr pctxt,
1c8959
 }
1c8959
 #endif
1c8959
 
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(5,0)
1c8959
 xmlSchemaCustomErr4(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 		   xmlParserErrors error,
1c8959
 		   xmlNodePtr node,
1c8959
@@ -2334,7 +2334,7 @@ xmlSchemaCustomErr4(xmlSchemaAbstractCtxtPtr actxt,
1c8959
     FREE_AND_NULL(msg)
1c8959
 }
1c8959
 
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(5,0)
1c8959
 xmlSchemaCustomErr(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 		   xmlParserErrors error,
1c8959
 		   xmlNodePtr node,
1c8959
@@ -2349,7 +2349,7 @@ xmlSchemaCustomErr(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 
1c8959
 
1c8959
 
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(5,0)
1c8959
 xmlSchemaCustomWarning(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 		   xmlParserErrors error,
1c8959
 		   xmlNodePtr node,
1c8959
@@ -2374,7 +2374,7 @@ xmlSchemaCustomWarning(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 
1c8959
 
1c8959
 
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(5,0)
1c8959
 xmlSchemaKeyrefErr(xmlSchemaValidCtxtPtr vctxt,
1c8959
 		   xmlParserErrors error,
1c8959
 		   xmlSchemaPSVIIDCNodePtr idcNode,
1c8959
@@ -2523,7 +2523,7 @@ xmlSchemaIllegalAttrErr(xmlSchemaAbstractCtxtPtr actxt,
1c8959
     FREE_AND_NULL(msg)
1c8959
 }
1c8959
 
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(5,0)
1c8959
 xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 		        xmlParserErrors error,
1c8959
 		        xmlNodePtr node,
1c8959
@@ -2623,7 +2623,7 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt,
1c8959
     xmlFree(msg);
1c8959
 }
1c8959
 
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(8,0)
1c8959
 xmlSchemaFacetErr(xmlSchemaAbstractCtxtPtr actxt,
1c8959
 		  xmlParserErrors error,
1c8959
 		  xmlNodePtr node,
1c8959
@@ -2914,7 +2914,7 @@ xmlSchemaPIllegalAttrErr(xmlSchemaParserCtxtPtr ctxt,
1c8959
  *
1c8959
  * Reports an error during parsing.
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(5,0)
1c8959
 xmlSchemaPCustomErrExt(xmlSchemaParserCtxtPtr ctxt,
1c8959
 		    xmlParserErrors error,
1c8959
 		    xmlSchemaBasicItemPtr item,
1c8959
@@ -2950,7 +2950,7 @@ xmlSchemaPCustomErrExt(xmlSchemaParserCtxtPtr ctxt,
1c8959
  *
1c8959
  * Reports an error during parsing.
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(5,0)
1c8959
 xmlSchemaPCustomErr(xmlSchemaParserCtxtPtr ctxt,
1c8959
 		    xmlParserErrors error,
1c8959
 		    xmlSchemaBasicItemPtr item,
1c8959
@@ -2975,7 +2975,7 @@ xmlSchemaPCustomErr(xmlSchemaParserCtxtPtr ctxt,
1c8959
  *
1c8959
  * Reports an attribute use error during parsing.
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(6,0)
1c8959
 xmlSchemaPAttrUseErr4(xmlSchemaParserCtxtPtr ctxt,
1c8959
 		    xmlParserErrors error,
1c8959
 		    xmlNodePtr node,
1c8959
@@ -3097,7 +3097,7 @@ xmlSchemaPMutualExclAttrErr(xmlSchemaParserCtxtPtr ctxt,
1c8959
  * Reports a simple type validation error.
1c8959
  * TODO: Should this report the value of an element as well?
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(8,0)
1c8959
 xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt,
1c8959
 			xmlParserErrors error,
1c8959
 			xmlSchemaBasicItemPtr ownerItem ATTRIBUTE_UNUSED,
1c8959
diff --git a/xmlstring.c b/xmlstring.c
1c8959
index d465c23..c66eef3 100644
1c8959
--- a/xmlstring.c
1c8959
+++ b/xmlstring.c
1c8959
@@ -545,7 +545,7 @@ xmlStrcat(xmlChar *cur, const xmlChar *add) {
1c8959
  * Returns the number of characters written to @buf or -1 if an error occurs.
1c8959
  */
1c8959
 int XMLCDECL
1c8959
-xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg, ...) {
1c8959
+xmlStrPrintf(xmlChar *buf, int len, const char *msg, ...) {
1c8959
     va_list args;
1c8959
     int ret;
1c8959
 
1c8959
@@ -573,7 +573,7 @@ xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg, ...) {
1c8959
  * Returns the number of characters written to @buf or -1 if an error occurs.
1c8959
  */
1c8959
 int
1c8959
-xmlStrVPrintf(xmlChar *buf, int len, const xmlChar *msg, va_list ap) {
1c8959
+xmlStrVPrintf(xmlChar *buf, int len, const char *msg, va_list ap) {
1c8959
     int ret;
1c8959
 
1c8959
     if((buf == NULL) || (msg == NULL)) {
1c8959
diff --git a/xmlwriter.c b/xmlwriter.c
1c8959
index d3f29f8..92c4bb2 100644
1c8959
--- a/xmlwriter.c
1c8959
+++ b/xmlwriter.c
1c8959
@@ -109,7 +109,7 @@ static int xmlTextWriterWriteDocCallback(void *context,
1c8959
                                          const xmlChar * str, int len);
1c8959
 static int xmlTextWriterCloseDocCallback(void *context);
1c8959
 
1c8959
-static xmlChar *xmlTextWriterVSprintf(const char *format, va_list argptr);
1c8959
+static xmlChar *xmlTextWriterVSprintf(const char *format, va_list argptr) LIBXML_ATTR_FORMAT(1,0);
1c8959
 static int xmlOutputBufferWriteBase64(xmlOutputBufferPtr out, int len,
1c8959
                                       const unsigned char *data);
1c8959
 static void xmlTextWriterStartDocumentCallback(void *ctx);
1c8959
@@ -149,7 +149,7 @@ xmlWriterErrMsg(xmlTextWriterPtr ctxt, xmlParserErrors error,
1c8959
  *
1c8959
  * Handle a writer error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlWriterErrMsgInt(xmlTextWriterPtr ctxt, xmlParserErrors error,
1c8959
                const char *msg, int val)
1c8959
 {
1c8959
diff --git a/xpath.c b/xpath.c
1c8959
index 97410e7..6ddf491 100644
1c8959
--- a/xpath.c
1c8959
+++ b/xpath.c
1c8959
@@ -348,7 +348,7 @@ xmlXPathErrMemory(xmlXPathContextPtr ctxt, const char *extra)
1c8959
             xmlChar buf[200];
1c8959
 
1c8959
             xmlStrPrintf(buf, 200,
1c8959
-                         BAD_CAST "Memory allocation failed : %s\n",
1c8959
+                         "Memory allocation failed : %s\n",
1c8959
                          extra);
1c8959
             ctxt->lastError.message = (char *) xmlStrdup(buf);
1c8959
         } else {
1c8959
diff --git a/xpointer.c b/xpointer.c
1c8959
index 46f11e8..1a48812 100644
1c8959
--- a/xpointer.c
1c8959
+++ b/xpointer.c
1c8959
@@ -85,7 +85,7 @@ xmlXPtrErrMemory(const char *extra)
1c8959
  *
1c8959
  * Handle a redefinition of attribute error
1c8959
  */
1c8959
-static void
1c8959
+static void LIBXML_ATTR_FORMAT(3,0)
1c8959
 xmlXPtrErr(xmlXPathParserContextPtr ctxt, int error,
1c8959
            const char * msg, const xmlChar *extra)
1c8959
 {
1c8959
-- 
1c8959
2.5.5
1c8959