- Timestamp:
- Oct 7, 2015 9:47:57 AM (9 years ago)
- Location:
- trunk/src/libs/libxml2-2.9.2
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/libxml2-2.9.2/buf.c
r58072 r58076 28 28 #include <libxml/globals.h> 29 29 #include <libxml/tree.h> 30 #include <libxml/parserInternals.h> /* for XML_MAX_TEXT_LENGTH */ 30 31 #include "buf.h" 31 32 … … 300 301 (scheme == XML_BUFFER_ALLOC_EXACT) || 301 302 (scheme == XML_BUFFER_ALLOC_HYBRID) || 302 (scheme == XML_BUFFER_ALLOC_IMMUTABLE)) { 303 (scheme == XML_BUFFER_ALLOC_IMMUTABLE) || 304 (scheme == XML_BUFFER_ALLOC_BOUNDED)) { 303 305 buf->alloc = scheme; 304 306 if (buf->buffer) … … 459 461 #endif 460 462 463 if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) { 464 /* 465 * Used to provide parsing limits 466 */ 467 if ((buf->use + len >= XML_MAX_TEXT_LENGTH) || 468 (buf->size >= XML_MAX_TEXT_LENGTH)) { 469 xmlBufMemoryError(buf, "buffer error: text too long\n"); 470 return(0); 471 } 472 if (size >= XML_MAX_TEXT_LENGTH) 473 size = XML_MAX_TEXT_LENGTH; 474 } 461 475 if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) { 462 476 size_t start_buf = buf->content - buf->contentIO; … … 740 754 741 755 if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0); 756 if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) { 757 /* 758 * Used to provide parsing limits 759 */ 760 if (size >= XML_MAX_TEXT_LENGTH) { 761 xmlBufMemoryError(buf, "buffer error: text too long\n"); 762 return(0); 763 } 764 } 742 765 743 766 /* Don't resize if we don't have to */ … … 868 891 needSize = buf->use + len + 2; 869 892 if (needSize > buf->size){ 893 if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) { 894 /* 895 * Used to provide parsing limits 896 */ 897 if (needSize >= XML_MAX_TEXT_LENGTH) { 898 xmlBufMemoryError(buf, "buffer error: text too long\n"); 899 return(-1); 900 } 901 } 870 902 if (!xmlBufResize(buf, needSize)){ 871 903 xmlBufMemoryError(buf, "growing buffer"); … … 939 971 needSize = buf->use + len + 2; 940 972 if (needSize > buf->size){ 973 if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) { 974 /* 975 * Used to provide parsing limits 976 */ 977 if (needSize >= XML_MAX_TEXT_LENGTH) { 978 xmlBufMemoryError(buf, "buffer error: text too long\n"); 979 return(-1); 980 } 981 } 941 982 if (!xmlBufResize(buf, needSize)){ 942 983 xmlBufMemoryError(buf, "growing buffer"); -
trunk/src/libs/libxml2-2.9.2/include/libxml/tree.h
r58072 r58076 77 77 XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer */ 78 78 XML_BUFFER_ALLOC_IO, /* special allocation scheme used for I/O */ 79 XML_BUFFER_ALLOC_HYBRID /* exact up to a threshold, and doubleit thereafter */ 79 XML_BUFFER_ALLOC_HYBRID, /* exact up to a threshold, and doubleit thereafter */ 80 XML_BUFFER_ALLOC_BOUNDED /* limit the upper size of the buffer */ 80 81 } xmlBufferAllocationScheme; 81 82 -
trunk/src/libs/libxml2-2.9.2/parser.c
r58072 r58076 5659 5659 xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED, 5660 5660 "xmlParseEntityDecl: entity %s not terminated\n", name); 5661 xmlStopParser(ctxt); 5661 5662 } else { 5662 5663 if (input != ctxt->input) { … … 6770 6771 if (RAW != '[') { 6771 6772 xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL); 6773 xmlStopParser(ctxt); 6774 return; 6772 6775 } else { 6773 6776 if (ctxt->input->id != id) { … … 6830 6833 if (RAW != '[') { 6831 6834 xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL); 6835 xmlStopParser(ctxt); 6836 return; 6832 6837 } else { 6833 6838 if (ctxt->input->id != id) { … … 6885 6890 } else { 6886 6891 xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID_KEYWORD, NULL); 6892 xmlStopParser(ctxt); 6893 return; 6887 6894 } 6888 6895 … … 7236 7243 * the document entity by default. 7237 7244 */ 7238 if ((ent->checked == 0) && 7245 if (((ent->checked == 0) || 7246 ((ent->children == NULL) && (ctxt->options & XML_PARSE_NOENT))) && 7239 7247 ((ent->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY) || 7240 7248 (ctxt->options & (XML_PARSE_NOENT | XML_PARSE_DTDVALID)))) { … … 10397 10405 if (RAW != '"') { 10398 10406 xmlFatalErr(ctxt, XML_ERR_STRING_NOT_CLOSED, NULL); 10407 xmlFree((xmlChar *) encoding); 10408 return(NULL); 10399 10409 } else 10400 10410 NEXT; … … 10404 10414 if (RAW != '\'') { 10405 10415 xmlFatalErr(ctxt, XML_ERR_STRING_NOT_CLOSED, NULL); 10416 xmlFree((xmlChar *) encoding); 10417 return(NULL); 10406 10418 } else 10407 10419 NEXT; … … 10460 10472 handler = xmlFindCharEncodingHandler((const char *) encoding); 10461 10473 if (handler != NULL) { 10462 xmlSwitchToEncoding(ctxt, handler); 10474 if (xmlSwitchToEncoding(ctxt, handler) < 0) { 10475 /* failed to convert */ 10476 ctxt->errNo = XML_ERR_UNSUPPORTED_ENCODING; 10477 return(NULL); 10478 } 10463 10479 } else { 10464 10480 xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING, … … 14831 14847 xmlXPathInit(); 14832 14848 #endif 14833 #ifdef LIBXML_CATALOG_ENABLED14834 xmlInitializeCatalog();14835 #endif14836 14849 xmlParserInitialized = 1; 14837 14850 #ifdef LIBXML_THREAD_ENABLED -
trunk/src/libs/libxml2-2.9.2/tree.c
r58072 r58076 2800 2800 prop = tree->properties; 2801 2801 while (prop != NULL) { 2802 if (prop->atype == XML_ATTRIBUTE_ID) { 2803 xmlRemoveID(tree->doc, prop); 2804 } 2805 2802 2806 prop->doc = doc; 2803 2807 xmlSetListDoc(prop->children, doc); 2808 2809 if (xmlIsID(doc, tree, prop)) { 2810 xmlChar *idVal = xmlNodeListGetString(doc, prop->children, 2811 1); 2812 xmlAddID(NULL, doc, idVal, prop); 2813 } 2814 2804 2815 prop = prop->next; 2805 2816 } -
trunk/src/libs/libxml2-2.9.2/valid.c
r58072 r58076 2635 2635 * The id is already defined in this DTD. 2636 2636 */ 2637 xmlErrValidNode(ctxt, attr->parent, XML_DTD_ID_REDEFINED, 2638 "ID %s already defined\n", value, NULL, NULL); 2637 if (ctxt != NULL) { 2638 xmlErrValidNode(ctxt, attr->parent, XML_DTD_ID_REDEFINED, 2639 "ID %s already defined\n", value, NULL, NULL); 2640 } 2639 2641 #endif /* LIBXML_VALID_ENABLED */ 2640 2642 xmlFreeID(ret); -
trunk/src/libs/libxml2-2.9.2/xmlmemory.c
r58072 r58076 555 555 int 556 556 xmlMemUsed(void) { 557 return(debugMemSize); 557 int res; 558 559 xmlMutexLock(xmlMemMutex); 560 res = debugMemSize; 561 xmlMutexUnlock(xmlMemMutex); 562 return(res); 558 563 } 559 564 … … 568 573 int 569 574 xmlMemBlocks(void) { 570 return(debugMemBlocks); 575 int res; 576 577 xmlMutexLock(xmlMemMutex); 578 res = debugMemBlocks; 579 xmlMutexUnlock(xmlMemMutex); 580 return(res); 571 581 } 572 582 -
trunk/src/libs/libxml2-2.9.2/xmlreader.c
r58072 r58076 2092 2092 return(NULL); 2093 2093 } 2094 /* no operation on a reader should require a huge buffer */ 2095 xmlBufSetAllocationScheme(ret->buffer, 2096 XML_BUFFER_ALLOC_BOUNDED); 2094 2097 ret->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler)); 2095 2098 if (ret->sax == NULL) { … … 3617 3620 case XML_ATTRIBUTE_NODE:{ 3618 3621 xmlAttrPtr attr = (xmlAttrPtr) node; 3622 const xmlChar *ret; 3619 3623 3620 3624 if ((attr->children != NULL) && … … 3630 3634 return (NULL); 3631 3635 } 3636 xmlBufSetAllocationScheme(reader->buffer, 3637 XML_BUFFER_ALLOC_BOUNDED); 3632 3638 } else 3633 3639 xmlBufEmpty(reader->buffer); 3634 3640 xmlBufGetNodeContent(reader->buffer, node); 3635 return(xmlBufContent(reader->buffer)); 3641 ret = xmlBufContent(reader->buffer); 3642 if (ret == NULL) { 3643 /* error on the buffer best to reallocate */ 3644 xmlBufFree(reader->buffer); 3645 reader->buffer = xmlBufCreateSize(100); 3646 xmlBufSetAllocationScheme(reader->buffer, 3647 XML_BUFFER_ALLOC_BOUNDED); 3648 ret = BAD_CAST ""; 3649 } 3650 return(ret); 3636 3651 } 3637 3652 break; … … 5132 5147 return (-1); 5133 5148 } 5149 /* no operation on a reader should require a huge buffer */ 5150 xmlBufSetAllocationScheme(reader->buffer, 5151 XML_BUFFER_ALLOC_BOUNDED); 5134 5152 if (reader->sax == NULL) 5135 5153 reader->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler)); -
trunk/src/libs/libxml2-2.9.2/xmlschemas.c
r58072 r58076 24187 24187 goto pattern_and_enum; 24188 24188 } 24189 24189 24190 /* 24190 24191 * Whitespace handling is only of importance for string-based … … 24197 24198 } else 24198 24199 ws = XML_SCHEMA_WHITESPACE_COLLAPSE; 24200 24199 24201 /* 24200 24202 * If the value was not computed (for string or … … 24202 24204 * type. 24203 24205 */ 24204 if (val == NULL) 24205 valType = valType; 24206 else 24206 if (val != NULL) 24207 24207 valType = xmlSchemaGetValType(val); 24208 24208 -
trunk/src/libs/libxml2-2.9.2/xpath.c
r58072 r58076 362 362 * compute depth to root 363 363 */ 364 for (depth2 = 0, cur = node2; cur->parent != NULL;cur = cur->parent) {365 if (cur == node1)364 for (depth2 = 0, cur = node2; cur->parent != NULL; cur = cur->parent) { 365 if (cur->parent == node1) 366 366 return(1); 367 367 depth2++; 368 368 } 369 369 root = cur; 370 for (depth1 = 0, cur = node1; cur->parent != NULL;cur = cur->parent) {371 if (cur == node2)370 for (depth1 = 0, cur = node1; cur->parent != NULL; cur = cur->parent) { 371 if (cur->parent == node2) 372 372 return(-1); 373 373 depth1++;
Note:
See TracChangeset
for help on using the changeset viewer.