Commit 635ef72a authored by Daniel Veillard's avatar Daniel Veillard
Browse files

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
parent 51095317
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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 @@ 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);
......
......@@ -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;
/*
......
......@@ -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) {
......
......@@ -9791,6 +9791,8 @@ xmlSAXParseFileWithData(xmlSAXHandlerPtr sax, const char *filename,
xmlParserCtxtPtr ctxt;
char *directory = NULL;
xmlInitParser();
ctxt = xmlCreateFileParserCtxt(filename);
if (ctxt == NULL) {
return(NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment