diff --git a/ChangeLog b/ChangeLog index a8e7a570..e5a5225b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Mon Oct 29 12:44:17 CET 2001 Daniel Veillard + + * 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 *doc/xmllint.xml, doc/xmllint.1 diff --git a/DOCBparser.c b/DOCBparser.c index 013e819b..80014385 100644 --- a/DOCBparser.c +++ b/DOCBparser.c @@ -5042,7 +5042,7 @@ docbInitParserCtxt(docbParserCtxtPtr ctxt) 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 0b9061d0..da4666c0 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -3747,6 +3747,7 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt) 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 0ba84cfa..15d6246f 100644 --- a/error.c +++ b/error.c @@ -14,6 +14,10 @@ #include #include +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 @@ xmlParserError(void *ctx, const char *msg, ...) 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 @@ xmlParserWarning(void *ctx, const char *msg, ...) 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 @@ xmlParserValidityError(void *ctx, const char *msg, ...) 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 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...) 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 cfa5ca66..e5b5bc8b 100644 --- a/globals.c +++ b/globals.c @@ -117,7 +117,10 @@ int xmlSubstituteEntitiesDefaultValue = 0; /* 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 e910fa08..8fd0d558 100644 --- a/nanoftp.c +++ b/nanoftp.c @@ -756,7 +756,7 @@ xmlNanoFTPSendUser(void *ctx) { 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 @@ xmlNanoFTPSendPasswd(void *ctx) { 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 @@ xmlNanoFTPQuit(void *ctx) { 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 @@ xmlNanoFTPConnect(void *ctx) { 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 @@ xmlNanoFTPConnect(void *ctx) { 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 @@ xmlNanoFTPConnect(void *ctx) { 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 @@ xmlNanoFTPConnect(void *ctx) { 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 @@ xmlNanoFTPConnect(void *ctx) { 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 @@ xmlNanoFTPCwd(void *ctx, char *directory) { 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 @@ xmlNanoFTPGetConnection(void *ctx) { 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 @@ xmlNanoFTPGetConnection(void *ctx) { 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 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData, 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 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) { 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 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) { 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 ab5ea0ad..bae06dc9 100644 --- a/parser.c +++ b/parser.c @@ -9791,6 +9791,8 @@ xmlSAXParseFileWithData(xmlSAXHandlerPtr sax, const char *filename, xmlParserCtxtPtr ctxt; char *directory = NULL; + xmlInitParser(); + ctxt = xmlCreateFileParserCtxt(filename); if (ctxt == NULL) { return(NULL);