Changeset 16778 in vbox for trunk/src/libs
- Timestamp:
- Feb 16, 2009 10:04:16 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 42849
- Location:
- trunk/src/libs/libxml2-2.6.30
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/libxml2-2.6.30/SAX2.c
r6076 r16778 12 12 #include <stdlib.h> 13 13 #include <string.h> 14 #include <limits.h> 14 15 #include <libxml/xmlmemory.h> 15 16 #include <libxml/tree.h> … … 26 27 #include <libxml/HTMLtree.h> 27 28 #include <libxml/globals.h> 29 30 /* Define SIZE_T_MAX unless defined through <limits.h>. */ 31 #ifndef SIZE_T_MAX 32 # define SIZE_T_MAX ((size_t)-1) 33 #endif /* !SIZE_T_MAX */ 28 34 29 35 /* #define DEBUG_SAX2 */ … … 581 587 } 582 588 ret->owner = 1; 583 ret->checked = 1; 589 if (ret->checked == 0) 590 ret->checked = 1; 584 591 } 585 592 return(ret); … … 2444 2451 lastChild->content = xmlStrdup(lastChild->content); 2445 2452 } 2453 if ((size_t)ctxt->nodelen > SIZE_T_MAX - (size_t)len || 2454 (size_t)ctxt->nodemem + (size_t)len > SIZE_T_MAX / 2) { 2455 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters overflow prevented"); 2456 return; 2457 } 2446 2458 if (ctxt->nodelen + len >= ctxt->nodemem) { 2447 2459 xmlChar *newbuf; 2448 int size;2460 size_t size; 2449 2461 2450 2462 size = ctxt->nodemem + len; -
trunk/src/libs/libxml2-2.6.30/include/libxml/parser.h
r6076 r16778 298 298 xmlError lastError; 299 299 xmlParserMode parseMode; /* the parser mode */ 300 unsigned long nbentities; /* number of entities references */ 300 301 }; 301 302 -
trunk/src/libs/libxml2-2.6.30/parser.c
r6076 r16778 2181 2181 last = str + len; 2182 2182 2183 if ( ctxt->depth > 40) {2183 if ((ctxt->depth > 40) || (ctxt->nbentities >= 500000)) { 2184 2184 xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); 2185 2185 return(NULL); … … 2219 2219 str); 2220 2220 ent = xmlParseStringEntityRef(ctxt, &str); 2221 if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP) 2222 goto int_error; 2223 ctxt->nbentities++; 2224 if (ent != NULL) 2225 ctxt->nbentities += ent->checked; 2221 2226 if ((ent != NULL) && 2222 2227 (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { … … 2265 2270 "String decoding PE Reference: %.30s\n", str); 2266 2271 ent = xmlParseStringPEReference(ctxt, &str); 2272 if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP) 2273 goto int_error; 2274 ctxt->nbentities++; 2275 if (ent != NULL) 2276 ctxt->nbentities += ent->checked; 2267 2277 if (ent != NULL) { 2268 2278 xmlChar *rep; … … 2301 2311 mem_error: 2302 2312 xmlErrMemory(ctxt, NULL); 2313 int_error: 2314 if (buffer != NULL) 2315 xmlFree(buffer); 2303 2316 return(NULL); 2304 2317 } … … 3110 3123 } else { 3111 3124 ent = xmlParseEntityRef(ctxt); 3125 ctxt->nbentities++; 3126 if (ent != NULL) 3127 ctxt->nbentities += ent->checked; 3112 3128 if ((ent != NULL) && 3113 3129 (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { … … 3584 3600 col = ctxt->input->col; 3585 3601 } 3602 /* something really bad happened in the SAX callback */ 3603 if (ctxt->instate != XML_PARSER_CONTENT) 3604 return; 3586 3605 } 3587 3606 ctxt->input->cur = in; … … 3664 3683 } 3665 3684 nbchar = 0; 3685 /* something really bad happened in the SAX callback */ 3686 if (ctxt->instate != XML_PARSER_CONTENT) 3687 return; 3666 3688 } 3667 3689 count++; … … 4392 4414 xmlChar *orig = NULL; 4393 4415 int skipped; 4416 unsigned long oldnbent = ctxt->nbentities; 4394 4417 4395 4418 /* GROW; done in the caller */ … … 4601 4624 } 4602 4625 if (cur != NULL) { 4626 cur->checked = ctxt->nbentities - oldnbent; 4603 4627 if (cur->orig != NULL) 4604 4628 xmlFree(orig); … … 5979 6003 if (!ctxt->wellFormed) 5980 6004 return; 6005 ctxt->nbentities++; 6006 if (ctxt->nbentities >= 500000) { 6007 xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); 6008 return; 6009 } 5981 6010 was_checked = ent->checked; 5982 6011 if ((ent->name != NULL) && … … 6039 6068 } 6040 6069 } else { 6070 unsigned long oldnbent = ctxt->nbentities; 6041 6071 /* 6042 6072 * 4.3.2: An internal general parsed entity is well-formed … … 6073 6103 "invalid entity type found\n", NULL); 6074 6104 } 6105 ent->checked = ctxt->nbentities - oldnbent; 6075 6106 if (ret == XML_ERR_ENTITY_LOOP) { 6076 6107 xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); … … 6129 6160 } 6130 6161 } 6131 ent->checked = 1; 6162 if (ent->checked == 0) 6163 ent->checked = 1; 6132 6164 } 6165 ctxt->nbentities += ent->checked; 6133 6166 6134 6167 if (ent->children == NULL) { … … 6139 6172 * content to generate callbacks associated to the entity 6140 6173 */ 6141 if (was_checked == 1) {6174 if (was_checked != 0) { 6142 6175 void *user_data; 6143 6176 /* … … 11154 11187 if (ctx == NULL) return(-1); 11155 11188 11156 if ( ctx->depth > 40) {11189 if ((ctx->depth > 40) || (ctx->nbentities >= 500000)) { 11157 11190 return(XML_ERR_ENTITY_LOOP); 11158 11191 } … … 11355 11388 xmlCharEncoding enc; 11356 11389 11357 if (depth > 40) { 11390 if ((depth > 40) || 11391 ((oldctxt != NULL) && (oldctxt->nbentities >= 500000))) { 11358 11392 return(XML_ERR_ENTITY_LOOP); 11359 11393 } … … 11498 11532 oldctxt->node_seq.length = ctxt->node_seq.length; 11499 11533 oldctxt->node_seq.buffer = ctxt->node_seq.buffer; 11534 oldctxt->nbentities += ctxt->nbentities; 11500 11535 ctxt->node_seq.maximum = 0; 11501 11536 ctxt->node_seq.length = 0; … … 11598 11633 xmlParserErrors ret = XML_ERR_OK; 11599 11634 11600 if ( oldctxt->depth > 40) {11635 if ((oldctxt->depth > 40) || (oldctxt->nbentities >= 500000)) { 11601 11636 return(XML_ERR_ENTITY_LOOP); 11602 11637 } … … 11721 11756 ctxt->myDoc->last = last; 11722 11757 } 11723 11758 11759 oldctxt->nbentities += ctxt->nbentities; 11724 11760 ctxt->sax = oldsax; 11725 11761 ctxt->dict = NULL; … … 13033 13069 ctxt->charset = XML_CHAR_ENCODING_UTF8; 13034 13070 ctxt->catalogs = NULL; 13071 ctxt->nbentities = 0; 13035 13072 xmlInitNodeInfoSeq(&ctxt->node_seq); 13036 13073 -
trunk/src/libs/libxml2-2.6.30/parserInternals.c
r6076 r16778 1658 1658 ctxt->charset = XML_CHAR_ENCODING_UTF8; 1659 1659 ctxt->catalogs = NULL; 1660 ctxt->nbentities = 0; 1660 1661 xmlInitNodeInfoSeq(&ctxt->node_seq); 1661 1662 return(0); -
trunk/src/libs/libxml2-2.6.30/tree.c
r6076 r16778 15 15 16 16 #include <string.h> /* for memset() only ! */ 17 17 #include <limits.h> 18 18 #ifdef HAVE_CTYPE_H 19 19 #include <ctype.h> … … 6899 6899 /*take care of empty case*/ 6900 6900 newSize = (buf->size ? buf->size*2 : size + 10); 6901 while (size > newSize) newSize *= 2; 6901 while (size > newSize) { 6902 if (newSize > UINT_MAX / 2) { 6903 xmlTreeErrMemory("growing buffer"); 6904 return 0; 6905 } 6906 newSize *= 2; 6907 } 6902 6908 break; 6903 6909 case XML_BUFFER_ALLOC_EXACT:
Note:
See TracChangeset
for help on using the changeset viewer.