apply fixes to close #63271 and avoid segfaults when the error routine
* parser.c globals.c DOCBparser.c HTMLparser.c error.c:
apply fixes to close #63271 and avoid segfaults when
the error routine gets callbed before xmlInitParser()
get called.
* nanoftp.c error.c: Applied patches from Justin Fletcher
correcting some xmlGenericError misuses.
Daniel
diff --git a/ChangeLog b/ChangeLog
index a8e7a57..e5a5225 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Mon Oct 29 12:44:17 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c globals.c DOCBparser.c HTMLparser.c error.c:
+ apply fixes to close #63271 and avoid segfaults when
+ the error routine gets callbed before xmlInitParser()
+ get called.
+ * nanoftp.c error.c: Applied patches from Justin Fletcher
+ correcting some xmlGenericError misuses.
+
Sat Oct 27 14:04:45 MDT 2001 John Fleck <jfleck@inkstain.net>
*doc/xmllint.xml, doc/xmllint.1
diff --git a/DOCBparser.c b/DOCBparser.c
index 013e819..8001438 100644
--- a/DOCBparser.c
+++ b/DOCBparser.c
@@ -5042,7 +5042,7 @@
ctxt->userData = ctxt;
ctxt->myDoc = NULL;
ctxt->wellFormed = 1;
- ctxt->linenumbers = 1;
+ ctxt->linenumbers = xmlLineNumbersDefaultValue;
ctxt->replaceEntities = xmlSubstituteEntitiesDefaultValue;
ctxt->html = 2;
ctxt->record_info = 0;
diff --git a/HTMLparser.c b/HTMLparser.c
index 0b9061d..da4666c 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -3747,6 +3747,7 @@
ctxt->myDoc = NULL;
ctxt->wellFormed = 1;
ctxt->replaceEntities = 0;
+ ctxt->linenumbers = xmlLineNumbersDefaultValue;
ctxt->html = 1;
ctxt->record_info = 0;
ctxt->validate = 0;
diff --git a/error.c b/error.c
index 0ba84cf..15d6246 100644
--- a/error.c
+++ b/error.c
@@ -14,6 +14,10 @@
#include <libxml/xmlmemory.h>
#include <libxml/globals.h>
+void xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
+ const char *msg,
+ ...);
+
#define XML_GET_VAR_STR(msg, str) { \
int size; \
int chars; \
@@ -58,7 +62,7 @@
*
* Default handler for out of context error messages.
*/
-static void
+void
xmlGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
va_list args;
@@ -261,7 +265,7 @@
xmlGenericError(xmlGenericErrorContext, "error: ");
XML_GET_VAR_STR(msg, str);
- xmlGenericError(xmlGenericErrorContext, str);
+ xmlGenericError(xmlGenericErrorContext, "%s", str);
if (str != NULL)
xmlFree(str);
@@ -304,7 +308,7 @@
xmlGenericError(xmlGenericErrorContext, "warning: ");
XML_GET_VAR_STR(msg, str);
- xmlGenericError(xmlGenericErrorContext, str);
+ xmlGenericError(xmlGenericErrorContext, "%s", str);
if (str != NULL)
xmlFree(str);
@@ -350,7 +354,7 @@
xmlGenericError(xmlGenericErrorContext, "validity error: ");
XML_GET_VAR_STR(msg, str);
- xmlGenericError(xmlGenericErrorContext, str);
+ xmlGenericError(xmlGenericErrorContext, "%s", str);
if (str != NULL)
xmlFree(str);
@@ -385,7 +389,7 @@
xmlGenericError(xmlGenericErrorContext, "validity warning: ");
XML_GET_VAR_STR(msg, str);
- xmlGenericError(xmlGenericErrorContext, str);
+ xmlGenericError(xmlGenericErrorContext, "%s", str);
if (str != NULL)
xmlFree(str);
diff --git a/globals.c b/globals.c
index cfa5ca6..e5b5bc8 100644
--- a/globals.c
+++ b/globals.c
@@ -117,7 +117,10 @@
/* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
/* Must initialize xmlGenericError in xmlInitParser */
-xmlGenericErrorFunc xmlGenericError;
+void xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
+ const char *msg,
+ ...);
+xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
void *xmlGenericErrorContext = NULL;
/*
diff --git a/nanoftp.c b/nanoftp.c
index e910fa0..8fd0d55 100644
--- a/nanoftp.c
+++ b/nanoftp.c
@@ -756,7 +756,7 @@
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
- xmlGenericError(xmlGenericErrorContext, buf);
+ xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
res = send(ctxt->controlFd, buf, len, 0);
if (res < 0) return(res);
@@ -781,7 +781,7 @@
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
- xmlGenericError(xmlGenericErrorContext, buf);
+ xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
res = send(ctxt->controlFd, buf, len, 0);
if (res < 0) return(res);
@@ -808,7 +808,7 @@
sprintf(buf, "QUIT\r\n");
len = strlen(buf);
#ifdef DEBUG_FTP
- xmlGenericError(xmlGenericErrorContext, buf);
+ xmlGenericError(xmlGenericErrorContext, "%s", buf); /* Just to be consistent, even though we know it can't have a % in it */
#endif
res = send(ctxt->controlFd, buf, len, 0);
return(0);
@@ -930,7 +930,7 @@
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
- xmlGenericError(xmlGenericErrorContext, buf);
+ xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
res = send(ctxt->controlFd, buf, len, 0);
if (res < 0) {
@@ -951,7 +951,7 @@
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
- xmlGenericError(xmlGenericErrorContext, buf);
+ xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
res = send(ctxt->controlFd, buf, len, 0);
if (res < 0) {
@@ -991,7 +991,7 @@
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
- xmlGenericError(xmlGenericErrorContext, buf);
+ xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
res = send(ctxt->controlFd, buf, len, 0);
if (res < 0) {
@@ -1021,7 +1021,7 @@
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
- xmlGenericError(xmlGenericErrorContext, buf);
+ xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
res = send(ctxt->controlFd, buf, len, 0);
if (res < 0) {
@@ -1042,7 +1042,7 @@
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
- xmlGenericError(xmlGenericErrorContext, buf);
+ xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
res = send(ctxt->controlFd, buf, len, 0);
if (res < 0) {
@@ -1180,7 +1180,7 @@
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
- xmlGenericError(xmlGenericErrorContext, buf);
+ xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
res = send(ctxt->controlFd, buf, len, 0);
if (res < 0) return(res);
@@ -1230,7 +1230,7 @@
sprintf(buf, "PASV\r\n");
len = strlen(buf);
#ifdef DEBUG_FTP
- xmlGenericError(xmlGenericErrorContext, buf);
+ xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
res = send(ctxt->controlFd, buf, len, 0);
if (res < 0) {
@@ -1296,7 +1296,7 @@
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
- xmlGenericError(xmlGenericErrorContext, buf);
+ xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
res = send(ctxt->controlFd, buf, len, 0);
@@ -1530,7 +1530,7 @@
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
- xmlGenericError(xmlGenericErrorContext, buf);
+ xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
res = send(ctxt->controlFd, buf, len, 0);
if (res < 0) {
@@ -1624,7 +1624,7 @@
sprintf(buf, "TYPE I\r\n");
len = strlen(buf);
#ifdef DEBUG_FTP
- xmlGenericError(xmlGenericErrorContext, buf);
+ xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
res = send(ctxt->controlFd, buf, len, 0);
if (res < 0) {
@@ -1643,7 +1643,7 @@
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
- xmlGenericError(xmlGenericErrorContext, buf);
+ xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
res = send(ctxt->controlFd, buf, len, 0);
if (res < 0) {
diff --git a/parser.c b/parser.c
index ab5ea0a..bae06dc 100644
--- a/parser.c
+++ b/parser.c
@@ -9791,6 +9791,8 @@
xmlParserCtxtPtr ctxt;
char *directory = NULL;
+ xmlInitParser();
+
ctxt = xmlCreateFileParserCtxt(filename);
if (ctxt == NULL) {
return(NULL);