1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-08-08 17:42:14 +03:00

remove the warning for startDocument(), as it is used by glade (or

* legacy.c: remove the warning for startDocument(), as it is used by
  glade (or glade-python)
* parser.c relaxng.c xmlschemastypes.c: fixed an assorted set of
  invalid accesses found by running some Python based regression
  tests under valgrind. There is still a few leaks reported by the
  relaxng regressions which need some attention.
* doc/Makefile.am: fixed a make install problem c.f. #124539
* include/libxml/parserInternals.h: addition of xmlParserMaxDepth
  patch from crutcher
Daniel
This commit is contained in:
Daniel Veillard
2003-10-17 12:43:59 +00:00
parent 520f58544a
commit 4aede2e66b
7 changed files with 106 additions and 64 deletions

View File

@@ -1,3 +1,15 @@
Fri Oct 17 14:38:54 CEST 2003 Daniel Veillard <daniel@veillard.com>
* legacy.c: remove the warning for startDocument(), as it is used by
glade (or glade-python)
* parser.c relaxng.c xmlschemastypes.c: fixed an assorted set of
invalid accesses found by running some Python based regression
tests under valgrind. There is still a few leaks reported by the
relaxng regressions which need some attention.
* doc/Makefile.am: fixed a make install problem c.f. #124539
* include/libxml/parserInternals.h: addition of xmlParserMaxDepth
patch from crutcher
Wed Oct 15 12:47:33 CEST 2003 Daniel Veillard <daniel@veillard.com> Wed Oct 15 12:47:33 CEST 2003 Daniel Veillard <daniel@veillard.com>
* parser.c: Marc Liyanage pointed out that xmlCleanupParser() * parser.c: Marc Liyanage pointed out that xmlCleanupParser()

View File

@@ -100,8 +100,10 @@ rebuild: libxml-sections.txt templates xml html api
install-data-local: install-data-local:
$(mkinstalldirs) $(DESTDIR)$(TARGET_DIR) $(mkinstalldirs) $(DESTDIR)$(TARGET_DIR)
-@INSTALL@ -m 0644 $(srcdir)/xml.html $(srcdir)/encoding.html $(srcdir)/FAQ.html $(srcdir)/structure.gif $(srcdir)/DOM.gif $(srcdir)/smallfootonly.gif $(srcdir)/redhat.gif $(srcdir)/libxml.gif $(srcdir)/w3c.png $(srcdir)/Libxml2-Logo-180x168.gif $(srcdir)/Libxml2-Logo-90x34.gif $(DESTDIR)$(TARGET_DIR) -@INSTALL@ -m 0644 $(srcdir)/xml.html $(srcdir)/encoding.html $(srcdir)/FAQ.html $(srcdir)/structure.gif $(srcdir)/DOM.gif $(srcdir)/smallfootonly.gif $(srcdir)/redhat.gif $(srcdir)/libxml.gif $(srcdir)/w3c.png $(srcdir)/Libxml2-Logo-180x168.gif $(srcdir)/Libxml2-Logo-90x34.gif $(DESTDIR)$(TARGET_DIR)
-@INSTALL@ -m 0644 $(srcdir)/html/*.html $(DESTDIR)$(TARGET_DIR) $(mkinstalldirs) $(DESTDIR)$(TARGET_DIR)/html
-@INSTALL@ -m 0644 $(srcdir)/html/index.sgml $(DESTDIR)$(TARGET_DIR) -@INSTALL@ -m 0644 $(srcdir)/html/*.html $(DESTDIR)$(TARGET_DIR)/html
-@INSTALL@ -m 0644 $(srcdir)/html/*.png $(DESTDIR)$(TARGET_DIR)/html
-@INSTALL@ -m 0644 $(srcdir)/html/index.sgml $(DESTDIR)$(TARGET_DIR)/html
-(cd $(DESTDIR); gtkdoc-fixxref --module=libxml --html-dir=$(HTML_DIR)) -(cd $(DESTDIR); gtkdoc-fixxref --module=libxml --html-dir=$(HTML_DIR))
-@(tar cf - tutorial | (cd $(DESTDIR)$(TARGET_DIR) && tar xvf -)) -@(tar cf - tutorial | (cd $(DESTDIR)$(TARGET_DIR) && tar xvf -))

View File

@@ -19,6 +19,15 @@
extern "C" { extern "C" {
#endif #endif
/**
* xmlParserMaxDepth:
*
* arbitrary depth limit for the XML documents that we allow to
* process. This is not a limitation of the parser but a safety
* boundary feature.
*/
XMLPUBVAR unsigned int xmlParserMaxDepth;
/** /**
* XML_MAX_NAMELEN: * XML_MAX_NAMELEN:
* *

View File

@@ -1084,7 +1084,8 @@ setDocumentLocator(void *ctx ATTRIBUTE_UNUSED,
void void
startDocument(void *ctx) startDocument(void *ctx)
{ {
DEPRECATED("startDocument") /* don't be too painful for glade users */
/* DEPRECATED("startDocument") */
xmlSAX2StartDocument(ctx); xmlSAX2StartDocument(ctx);
} }

View File

@@ -78,13 +78,13 @@
#endif #endif
/** /**
* MAX_DEPTH: * xmlParserMaxDepth:
* *
* arbitrary depth limit for the XML documents that we allow to * arbitrary depth limit for the XML documents that we allow to
* process. This is not a limitation of the parser but a safety * process. This is not a limitation of the parser but a safety
* boundary feature. * boundary feature.
*/ */
#define MAX_DEPTH 1024 unsigned int xmlParserMaxDepth = 1024;
#define SAX2 1 #define SAX2 1
@@ -972,15 +972,13 @@ nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
return (0); return (0);
} }
} }
#ifdef MAX_DEPTH if (((unsigned int) ctxt->nodeNr) > xmlParserMaxDepth) {
if (ctxt->nodeNr > MAX_DEPTH) {
xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR, xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
"Excessive depth in document: change MAX_DEPTH = %d\n", "Excessive depth in document: change xmlParserMaxDepth = %d\n",
MAX_DEPTH); xmlParserMaxDepth);
ctxt->instate = XML_PARSER_EOF; ctxt->instate = XML_PARSER_EOF;
return(0); return(0);
} }
#endif
ctxt->nodeTab[ctxt->nodeNr] = value; ctxt->nodeTab[ctxt->nodeNr] = value;
ctxt->node = value; ctxt->node = value;
return (ctxt->nodeNr++); return (ctxt->nodeNr++);
@@ -3101,6 +3099,8 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
} }
if (name != NULL) if (name != NULL)
xmlFree(name); xmlFree(name);
if (*cur == 0)
break;
} }
cur++; cur++;
} }
@@ -3810,10 +3810,16 @@ xmlParseComment(xmlParserCtxtPtr ctxt) {
return; return;
} }
q = CUR_CHAR(ql); q = CUR_CHAR(ql);
if (q == 0)
goto not_terminated;
NEXTL(ql); NEXTL(ql);
r = CUR_CHAR(rl); r = CUR_CHAR(rl);
if (r == 0)
goto not_terminated;
NEXTL(rl); NEXTL(rl);
cur = CUR_CHAR(l); cur = CUR_CHAR(l);
if (cur == 0)
goto not_terminated;
len = 0; len = 0;
while (xmlIsChar(cur) && /* checked */ while (xmlIsChar(cur) && /* checked */
((cur != '>') || ((cur != '>') ||
@@ -3866,6 +3872,11 @@ xmlParseComment(xmlParserCtxtPtr ctxt) {
xmlFree(buf); xmlFree(buf);
} }
ctxt->instate = state; ctxt->instate = state;
return;
not_terminated:
xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
"Comment not terminated\n", NULL);
xmlFree(buf);
} }
/** /**
@@ -5763,7 +5774,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
/* /*
* Check that this entity is well formed * Check that this entity is well formed
*/ */
if ((value != NULL) && if ((value != NULL) && (value[0] != 0) &&
(value[1] == 0) && (value[0] == '<') && (value[1] == 0) && (value[0] == '<') &&
(xmlStrEqual(ent->name, BAD_CAST "lt"))) { (xmlStrEqual(ent->name, BAD_CAST "lt"))) {
/* /*
@@ -8776,7 +8787,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator); ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
if (ctxt->encoding == (const xmlChar *)XML_CHAR_ENCODING_NONE) { if ((ctxt->encoding == (const xmlChar *)XML_CHAR_ENCODING_NONE) &&
((ctxt->input->end - ctxt->input->cur) >= 4)) {
/* /*
* Get the 4 first bytes and decode the charset * Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE * if enc != XML_CHAR_ENCODING_NONE
@@ -8786,7 +8798,7 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
start[1] = NXT(1); start[1] = NXT(1);
start[2] = NXT(2); start[2] = NXT(2);
start[3] = NXT(3); start[3] = NXT(3);
enc = xmlDetectCharEncoding(start, 4); enc = xmlDetectCharEncoding(&start[0], 4);
if (enc != XML_CHAR_ENCODING_NONE) { if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc); xmlSwitchEncoding(ctxt, enc);
} }
@@ -8938,13 +8950,15 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
* if enc != XML_CHAR_ENCODING_NONE * if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines. * plug some encoding conversion routines.
*/ */
start[0] = RAW; if ((ctxt->input->end - ctxt->input->cur) >= 4) {
start[1] = NXT(1); start[0] = RAW;
start[2] = NXT(2); start[1] = NXT(1);
start[3] = NXT(3); start[2] = NXT(2);
enc = xmlDetectCharEncoding(start, 4); start[3] = NXT(3);
if (enc != XML_CHAR_ENCODING_NONE) { enc = xmlDetectCharEncoding(start, 4);
xmlSwitchEncoding(ctxt, enc); if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc);
}
} }
@@ -10314,7 +10328,8 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
ctxt->myDoc->extSubset = xmlNewDtd(ctxt->myDoc, BAD_CAST "none", ctxt->myDoc->extSubset = xmlNewDtd(ctxt->myDoc, BAD_CAST "none",
BAD_CAST "none", BAD_CAST "none"); BAD_CAST "none", BAD_CAST "none");
if (enc == XML_CHAR_ENCODING_NONE) { if ((enc == XML_CHAR_ENCODING_NONE) &&
((ctxt->input->end - ctxt->input->cur) >= 4)) {
/* /*
* Get the 4 first bytes and decode the charset * Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE * if enc != XML_CHAR_ENCODING_NONE
@@ -10410,8 +10425,10 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
* plug some encoding conversion routines here. * plug some encoding conversion routines here.
*/ */
xmlPushInput(ctxt, input); xmlPushInput(ctxt, input);
enc = xmlDetectCharEncoding(ctxt->input->cur, 4); if ((ctxt->input->end - ctxt->input->cur) >= 4) {
xmlSwitchEncoding(ctxt, enc); enc = xmlDetectCharEncoding(ctxt->input->cur, 4);
xmlSwitchEncoding(ctxt, enc);
}
if (input->filename == NULL) if (input->filename == NULL)
input->filename = (char *) xmlCanonicPath(SystemID); input->filename = (char *) xmlCanonicPath(SystemID);
@@ -10560,13 +10577,15 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
* plug some encoding conversion routines. * plug some encoding conversion routines.
*/ */
GROW GROW
start[0] = RAW; if ((ctxt->input->end - ctxt->input->cur) >= 4) {
start[1] = NXT(1); start[0] = RAW;
start[2] = NXT(2); start[1] = NXT(1);
start[3] = NXT(3); start[2] = NXT(2);
enc = xmlDetectCharEncoding(start, 4); start[3] = NXT(3);
if (enc != XML_CHAR_ENCODING_NONE) { enc = xmlDetectCharEncoding(start, 4);
xmlSwitchEncoding(ctxt, enc); if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc);
}
} }
/* /*
@@ -10756,13 +10775,15 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
* plug some encoding conversion routines. * plug some encoding conversion routines.
*/ */
GROW; GROW;
start[0] = RAW; if ((ctxt->input->end - ctxt->input->cur) >= 4) {
start[1] = NXT(1); start[0] = RAW;
start[2] = NXT(2); start[1] = NXT(1);
start[3] = NXT(3); start[2] = NXT(2);
enc = xmlDetectCharEncoding(start, 4); start[3] = NXT(3);
if (enc != XML_CHAR_ENCODING_NONE) { enc = xmlDetectCharEncoding(start, 4);
xmlSwitchEncoding(ctxt, enc); if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc);
}
} }
/* /*

View File

@@ -6696,11 +6696,11 @@ xmlRelaxNGNormExtSpace(xmlChar * value)
/* don't try to normalize the inner spaces */ /* don't try to normalize the inner spaces */
while (IS_BLANK(*cur)) while (IS_BLANK(*cur))
cur++; cur++;
*start++ = *cur++;
if (*cur == 0) { if (*cur == 0) {
*start = 0; *start = 0;
return; return;
} }
*start++ = *cur++;
} while (1); } while (1);
} }
} }

View File

@@ -2857,21 +2857,24 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
xmlSchemaFreeValue(q1); xmlSchemaFreeValue(q1);
return -1; return -1;
} else { } else {
int ret = 0;
/* normalize y - 14:00 */ /* normalize y - 14:00 */
q2 = xmlSchemaDateNormalize(y, -(14 * SECS_PER_HOUR)); q2 = xmlSchemaDateNormalize(y, -(14 * SECS_PER_HOUR));
q2d = _xmlSchemaDateCastYMToDays(q2) + q2->value.date.day; q2d = _xmlSchemaDateCastYMToDays(q2) + q2->value.date.day;
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
xmlSchemaFreeValue(q2);
if (p1d > q2d) if (p1d > q2d)
return 1; ret = 1;
else if (p1d == q2d) { else if (p1d == q2d) {
sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q2); sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q2);
if (sec > 0.0) if (sec > 0.0)
return 1; ret = 1;
else else
return 2; /* indeterminate */ ret = 2; /* indeterminate */
} }
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
xmlSchemaFreeValue(q2);
if (ret != 0)
return(ret);
} }
} else { } else {
xmlSchemaFreeValue(p1); xmlSchemaFreeValue(p1);
@@ -2899,28 +2902,25 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
xmlSchemaFreeValue(q1); xmlSchemaFreeValue(q1);
return -1; return -1;
} else { } else {
int ret = 0;
/* normalize x + 14:00 */ /* normalize x + 14:00 */
p2 = xmlSchemaDateNormalize(x, (14 * SECS_PER_HOUR)); p2 = xmlSchemaDateNormalize(x, (14 * SECS_PER_HOUR));
p2d = _xmlSchemaDateCastYMToDays(p2) + p2->value.date.day; p2d = _xmlSchemaDateCastYMToDays(p2) + p2->value.date.day;
if (p2d > q1d) { if (p2d > q1d) {
xmlSchemaFreeValue(p1); ret = 1;
xmlSchemaFreeValue(q1);
xmlSchemaFreeValue(p2);
return 1;
} else if (p2d == q1d) { } else if (p2d == q1d) {
sec = TIME_TO_NUMBER(p2) - TIME_TO_NUMBER(q1); sec = TIME_TO_NUMBER(p2) - TIME_TO_NUMBER(q1);
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
xmlSchemaFreeValue(p2);
if (sec > 0.0) if (sec > 0.0)
return 1; ret = 1;
else else
return 2; /* indeterminate */ ret = 2; /* indeterminate */
} }
xmlSchemaFreeValue(p1); xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1); xmlSchemaFreeValue(q1);
xmlSchemaFreeValue(p2); xmlSchemaFreeValue(p2);
if (ret != 0)
return(ret);
} }
} else { } else {
xmlSchemaFreeValue(p1); xmlSchemaFreeValue(p1);
@@ -2932,6 +2932,7 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
* if the same type then calculate the difference * if the same type then calculate the difference
*/ */
if (x->type == y->type) { if (x->type == y->type) {
int ret = 0;
q1 = xmlSchemaDateNormalize(y, 0); q1 = xmlSchemaDateNormalize(y, 0);
q1d = _xmlSchemaDateCastYMToDays(q1) + q1->value.date.day; q1d = _xmlSchemaDateCastYMToDays(q1) + q1->value.date.day;
@@ -2939,26 +2940,22 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
p1d = _xmlSchemaDateCastYMToDays(p1) + p1->value.date.day; p1d = _xmlSchemaDateCastYMToDays(p1) + p1->value.date.day;
if (p1d < q1d) { if (p1d < q1d) {
xmlSchemaFreeValue(p1); ret = -1;
xmlSchemaFreeValue(q1);
return -1;
} else if (p1d > q1d) { } else if (p1d > q1d) {
xmlSchemaFreeValue(p1); ret = 1;
xmlSchemaFreeValue(q1);
return 1;
} else { } else {
double sec; double sec;
sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q1); sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q1);
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
if (sec < 0.0) if (sec < 0.0)
return -1; ret = -1;
else if (sec > 0.0) else if (sec > 0.0)
return 1; ret = 1;
} }
return 0; xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
return(ret);
} }
switch (x->type) { switch (x->type) {