mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
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
This commit is contained in:
@ -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>
|
Sat Oct 27 14:04:45 MDT 2001 John Fleck <jfleck@inkstain.net>
|
||||||
|
|
||||||
*doc/xmllint.xml, doc/xmllint.1
|
*doc/xmllint.xml, doc/xmllint.1
|
||||||
|
@ -5042,7 +5042,7 @@ docbInitParserCtxt(docbParserCtxtPtr ctxt)
|
|||||||
ctxt->userData = ctxt;
|
ctxt->userData = ctxt;
|
||||||
ctxt->myDoc = NULL;
|
ctxt->myDoc = NULL;
|
||||||
ctxt->wellFormed = 1;
|
ctxt->wellFormed = 1;
|
||||||
ctxt->linenumbers = 1;
|
ctxt->linenumbers = xmlLineNumbersDefaultValue;
|
||||||
ctxt->replaceEntities = xmlSubstituteEntitiesDefaultValue;
|
ctxt->replaceEntities = xmlSubstituteEntitiesDefaultValue;
|
||||||
ctxt->html = 2;
|
ctxt->html = 2;
|
||||||
ctxt->record_info = 0;
|
ctxt->record_info = 0;
|
||||||
|
@ -3747,6 +3747,7 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
|
|||||||
ctxt->myDoc = NULL;
|
ctxt->myDoc = NULL;
|
||||||
ctxt->wellFormed = 1;
|
ctxt->wellFormed = 1;
|
||||||
ctxt->replaceEntities = 0;
|
ctxt->replaceEntities = 0;
|
||||||
|
ctxt->linenumbers = xmlLineNumbersDefaultValue;
|
||||||
ctxt->html = 1;
|
ctxt->html = 1;
|
||||||
ctxt->record_info = 0;
|
ctxt->record_info = 0;
|
||||||
ctxt->validate = 0;
|
ctxt->validate = 0;
|
||||||
|
14
error.c
14
error.c
@ -14,6 +14,10 @@
|
|||||||
#include <libxml/xmlmemory.h>
|
#include <libxml/xmlmemory.h>
|
||||||
#include <libxml/globals.h>
|
#include <libxml/globals.h>
|
||||||
|
|
||||||
|
void xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
|
||||||
|
const char *msg,
|
||||||
|
...);
|
||||||
|
|
||||||
#define XML_GET_VAR_STR(msg, str) { \
|
#define XML_GET_VAR_STR(msg, str) { \
|
||||||
int size; \
|
int size; \
|
||||||
int chars; \
|
int chars; \
|
||||||
@ -58,7 +62,7 @@
|
|||||||
*
|
*
|
||||||
* Default handler for out of context error messages.
|
* Default handler for out of context error messages.
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
xmlGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
|
xmlGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
@ -261,7 +265,7 @@ xmlParserError(void *ctx, const char *msg, ...)
|
|||||||
|
|
||||||
xmlGenericError(xmlGenericErrorContext, "error: ");
|
xmlGenericError(xmlGenericErrorContext, "error: ");
|
||||||
XML_GET_VAR_STR(msg, str);
|
XML_GET_VAR_STR(msg, str);
|
||||||
xmlGenericError(xmlGenericErrorContext, str);
|
xmlGenericError(xmlGenericErrorContext, "%s", str);
|
||||||
if (str != NULL)
|
if (str != NULL)
|
||||||
xmlFree(str);
|
xmlFree(str);
|
||||||
|
|
||||||
@ -304,7 +308,7 @@ xmlParserWarning(void *ctx, const char *msg, ...)
|
|||||||
|
|
||||||
xmlGenericError(xmlGenericErrorContext, "warning: ");
|
xmlGenericError(xmlGenericErrorContext, "warning: ");
|
||||||
XML_GET_VAR_STR(msg, str);
|
XML_GET_VAR_STR(msg, str);
|
||||||
xmlGenericError(xmlGenericErrorContext, str);
|
xmlGenericError(xmlGenericErrorContext, "%s", str);
|
||||||
if (str != NULL)
|
if (str != NULL)
|
||||||
xmlFree(str);
|
xmlFree(str);
|
||||||
|
|
||||||
@ -350,7 +354,7 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
|
|||||||
|
|
||||||
xmlGenericError(xmlGenericErrorContext, "validity error: ");
|
xmlGenericError(xmlGenericErrorContext, "validity error: ");
|
||||||
XML_GET_VAR_STR(msg, str);
|
XML_GET_VAR_STR(msg, str);
|
||||||
xmlGenericError(xmlGenericErrorContext, str);
|
xmlGenericError(xmlGenericErrorContext, "%s", str);
|
||||||
if (str != NULL)
|
if (str != NULL)
|
||||||
xmlFree(str);
|
xmlFree(str);
|
||||||
|
|
||||||
@ -385,7 +389,7 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...)
|
|||||||
|
|
||||||
xmlGenericError(xmlGenericErrorContext, "validity warning: ");
|
xmlGenericError(xmlGenericErrorContext, "validity warning: ");
|
||||||
XML_GET_VAR_STR(msg, str);
|
XML_GET_VAR_STR(msg, str);
|
||||||
xmlGenericError(xmlGenericErrorContext, str);
|
xmlGenericError(xmlGenericErrorContext, "%s", str);
|
||||||
if (str != NULL)
|
if (str != NULL)
|
||||||
xmlFree(str);
|
xmlFree(str);
|
||||||
|
|
||||||
|
@ -117,7 +117,10 @@ int xmlSubstituteEntitiesDefaultValue = 0;
|
|||||||
|
|
||||||
/* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
|
/* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
|
||||||
/* Must initialize xmlGenericError in xmlInitParser */
|
/* Must initialize xmlGenericError in xmlInitParser */
|
||||||
xmlGenericErrorFunc xmlGenericError;
|
void xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
|
||||||
|
const char *msg,
|
||||||
|
...);
|
||||||
|
xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
|
||||||
void *xmlGenericErrorContext = NULL;
|
void *xmlGenericErrorContext = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
28
nanoftp.c
28
nanoftp.c
@ -756,7 +756,7 @@ xmlNanoFTPSendUser(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
xmlGenericError(xmlGenericErrorContext, buf);
|
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) return(res);
|
if (res < 0) return(res);
|
||||||
@ -781,7 +781,7 @@ xmlNanoFTPSendPasswd(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
xmlGenericError(xmlGenericErrorContext, buf);
|
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) return(res);
|
if (res < 0) return(res);
|
||||||
@ -808,7 +808,7 @@ xmlNanoFTPQuit(void *ctx) {
|
|||||||
sprintf(buf, "QUIT\r\n");
|
sprintf(buf, "QUIT\r\n");
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#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
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
return(0);
|
return(0);
|
||||||
@ -930,7 +930,7 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
xmlGenericError(xmlGenericErrorContext, buf);
|
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -951,7 +951,7 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
xmlGenericError(xmlGenericErrorContext, buf);
|
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -991,7 +991,7 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
xmlGenericError(xmlGenericErrorContext, buf);
|
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -1021,7 +1021,7 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
xmlGenericError(xmlGenericErrorContext, buf);
|
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -1042,7 +1042,7 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
xmlGenericError(xmlGenericErrorContext, buf);
|
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -1180,7 +1180,7 @@ xmlNanoFTPCwd(void *ctx, char *directory) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
xmlGenericError(xmlGenericErrorContext, buf);
|
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) return(res);
|
if (res < 0) return(res);
|
||||||
@ -1230,7 +1230,7 @@ xmlNanoFTPGetConnection(void *ctx) {
|
|||||||
sprintf(buf, "PASV\r\n");
|
sprintf(buf, "PASV\r\n");
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
xmlGenericError(xmlGenericErrorContext, buf);
|
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -1296,7 +1296,7 @@ xmlNanoFTPGetConnection(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
xmlGenericError(xmlGenericErrorContext, buf);
|
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
@ -1530,7 +1530,7 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
xmlGenericError(xmlGenericErrorContext, buf);
|
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -1624,7 +1624,7 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
|
|||||||
sprintf(buf, "TYPE I\r\n");
|
sprintf(buf, "TYPE I\r\n");
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
xmlGenericError(xmlGenericErrorContext, buf);
|
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -1643,7 +1643,7 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
xmlGenericError(xmlGenericErrorContext, buf);
|
xmlGenericError(xmlGenericErrorContext, "%s", buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
|
2
parser.c
2
parser.c
@ -9791,6 +9791,8 @@ xmlSAXParseFileWithData(xmlSAXHandlerPtr sax, const char *filename,
|
|||||||
xmlParserCtxtPtr ctxt;
|
xmlParserCtxtPtr ctxt;
|
||||||
char *directory = NULL;
|
char *directory = NULL;
|
||||||
|
|
||||||
|
xmlInitParser();
|
||||||
|
|
||||||
ctxt = xmlCreateFileParserCtxt(filename);
|
ctxt = xmlCreateFileParserCtxt(filename);
|
||||||
if (ctxt == NULL) {
|
if (ctxt == NULL) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
Reference in New Issue
Block a user