diff options
| author | Andrej Valek <andrej.valek@siemens.com> | 2017-06-14 14:38:35 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-23 11:44:13 +0100 |
| commit | 6765fcec154b1c81250c124fcb46414dcac9be12 (patch) | |
| tree | 47e9fab01184dc23c02510deeb1c8de336130ddc /meta/recipes-core/libxml | |
| parent | 89531a512f012dfb1b77bdeca500d80228c9fc02 (diff) | |
| download | poky-6765fcec154b1c81250c124fcb46414dcac9be12.tar.gz | |
libxml2: Avoid reparsing and simplify control flow in xmlParseStartTag2
(From OE-Core rev: 4651afdd457eca06da07331186bf28b98df2eeff)
Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/libxml')
| -rw-r--r-- | meta/recipes-core/libxml/libxml2/libxml2-fix_and_simplify_xmlParseStartTag2.patch | 590 | ||||
| -rw-r--r-- | meta/recipes-core/libxml/libxml2_2.9.4.bb | 1 |
2 files changed, 591 insertions, 0 deletions
diff --git a/meta/recipes-core/libxml/libxml2/libxml2-fix_and_simplify_xmlParseStartTag2.patch b/meta/recipes-core/libxml/libxml2/libxml2-fix_and_simplify_xmlParseStartTag2.patch new file mode 100644 index 0000000000..faa57701f5 --- /dev/null +++ b/meta/recipes-core/libxml/libxml2/libxml2-fix_and_simplify_xmlParseStartTag2.patch | |||
| @@ -0,0 +1,590 @@ | |||
| 1 | libxml2-2.9.4: Avoid reparsing and simplify control flow in xmlParseStartTag2 | ||
| 2 | |||
| 3 | [No upstream tracking] | ||
| 4 | |||
| 5 | parser: Avoid reparsing in xmlParseStartTag2 | ||
| 6 | |||
| 7 | The code in xmlParseStartTag2 must handle the case that the input | ||
| 8 | buffer was grown and reallocated which can invalidate pointers to | ||
| 9 | attribute values. Before, this was handled by detecting changes of | ||
| 10 | the input buffer "base" pointer and, in case of a change, jumping | ||
| 11 | back to the beginning of the function and reparsing the start tag. | ||
| 12 | |||
| 13 | The major problem of this approach is that whether an input buffer is | ||
| 14 | reallocated is nondeterministic, resulting in seemingly random test | ||
| 15 | failures. See the mailing list thread "runtest mystery bug: name2.xml | ||
| 16 | error case regression test" from 2012, for example. | ||
| 17 | |||
| 18 | If a reallocation was detected, the code also made no attempts to | ||
| 19 | continue parsing in case of errors which makes a difference in | ||
| 20 | the lax "recover" mode. | ||
| 21 | |||
| 22 | Now we store the current input buffer "base" pointer for each (not | ||
| 23 | separately allocated) attribute in the namespace URI field, which isn't | ||
| 24 | used until later. After the whole start tag was parsed, the pointers to | ||
| 25 | the attribute values are reconstructed using the offset between the | ||
| 26 | new and the old input buffer. This relies on arithmetic on dangling | ||
| 27 | pointers which is technically undefined behavior. But it seems like | ||
| 28 | the easiest and most efficient fix and a similar approach is used in | ||
| 29 | xmlParserInputGrow. | ||
| 30 | |||
| 31 | This changes the error output of several tests, typically making it | ||
| 32 | more verbose because we try harder to continue parsing in case of errors. | ||
| 33 | |||
| 34 | (Another possible solution is to check not only the "base" pointer | ||
| 35 | but the size of the input buffer as well. But this would result in | ||
| 36 | even more reparsing.) | ||
| 37 | |||
| 38 | Remove some goto labels and deduplicate a bit of code after handling | ||
| 39 | namespaces. | ||
| 40 | |||
| 41 | There were two bugs where parameter-entity references could lead to an | ||
| 42 | unexpected change of the input buffer in xmlParseNameComplex and | ||
| 43 | xmlDictLookup being called with an invalid pointer. | ||
| 44 | |||
| 45 | |||
| 46 | Upstream-Status: Backport | ||
| 47 | - [https://git.gnome.org/browse/libxml2/commit/?id=07b7428b69c368611d215a140fe630b2d1e61349] | ||
| 48 | - [https://git.gnome.org/browse/libxml2/commit/?id=855c19efb7cd30d927d673b3658563c4959ca6f0] | ||
| 49 | Signed-off-by: Andrej Valek <andrej.valek@siemens.com> | ||
| 50 | |||
| 51 | diff --git a/parser.c b/parser.c | ||
| 52 | index 609a270..74016e3 100644 | ||
| 53 | --- a/parser.c | ||
| 54 | +++ b/parser.c | ||
| 55 | @@ -43,6 +43,7 @@ | ||
| 56 | #include <limits.h> | ||
| 57 | #include <string.h> | ||
| 58 | #include <stdarg.h> | ||
| 59 | +#include <stddef.h> | ||
| 60 | #include <libxml/xmlmemory.h> | ||
| 61 | #include <libxml/threads.h> | ||
| 62 | #include <libxml/globals.h> | ||
| 63 | @@ -9377,8 +9378,7 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref, | ||
| 64 | const xmlChar **atts = ctxt->atts; | ||
| 65 | int maxatts = ctxt->maxatts; | ||
| 66 | int nratts, nbatts, nbdef; | ||
| 67 | - int i, j, nbNs, attval, oldline, oldcol, inputNr; | ||
| 68 | - const xmlChar *base; | ||
| 69 | + int i, j, nbNs, attval; | ||
| 70 | unsigned long cur; | ||
| 71 | int nsNr = ctxt->nsNr; | ||
| 72 | |||
| 73 | @@ -9392,13 +9392,8 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref, | ||
| 74 | * The Shrinking is only possible once the full set of attribute | ||
| 75 | * callbacks have been done. | ||
| 76 | */ | ||
| 77 | -reparse: | ||
| 78 | SHRINK; | ||
| 79 | - base = ctxt->input->base; | ||
| 80 | cur = ctxt->input->cur - ctxt->input->base; | ||
| 81 | - inputNr = ctxt->inputNr; | ||
| 82 | - oldline = ctxt->input->line; | ||
| 83 | - oldcol = ctxt->input->col; | ||
| 84 | nbatts = 0; | ||
| 85 | nratts = 0; | ||
| 86 | nbdef = 0; | ||
| 87 | @@ -9422,8 +9417,6 @@ reparse: | ||
| 88 | */ | ||
| 89 | SKIP_BLANKS; | ||
| 90 | GROW; | ||
| 91 | - if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) | ||
| 92 | - goto base_changed; | ||
| 93 | |||
| 94 | while (((RAW != '>') && | ||
| 95 | ((RAW != '/') || (NXT(1) != '>')) && | ||
| 96 | @@ -9434,203 +9427,174 @@ reparse: | ||
| 97 | |||
| 98 | attname = xmlParseAttribute2(ctxt, prefix, localname, | ||
| 99 | &aprefix, &attvalue, &len, &alloc); | ||
| 100 | - if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) { | ||
| 101 | - if ((attvalue != NULL) && (alloc != 0)) | ||
| 102 | - xmlFree(attvalue); | ||
| 103 | - attvalue = NULL; | ||
| 104 | - goto base_changed; | ||
| 105 | - } | ||
| 106 | - if ((attname != NULL) && (attvalue != NULL)) { | ||
| 107 | - if (len < 0) len = xmlStrlen(attvalue); | ||
| 108 | - if ((attname == ctxt->str_xmlns) && (aprefix == NULL)) { | ||
| 109 | - const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len); | ||
| 110 | - xmlURIPtr uri; | ||
| 111 | - | ||
| 112 | - if (URL == NULL) { | ||
| 113 | - xmlErrMemory(ctxt, "dictionary allocation failure"); | ||
| 114 | - if ((attvalue != NULL) && (alloc != 0)) | ||
| 115 | - xmlFree(attvalue); | ||
| 116 | - return(NULL); | ||
| 117 | - } | ||
| 118 | - if (*URL != 0) { | ||
| 119 | - uri = xmlParseURI((const char *) URL); | ||
| 120 | - if (uri == NULL) { | ||
| 121 | - xmlNsErr(ctxt, XML_WAR_NS_URI, | ||
| 122 | - "xmlns: '%s' is not a valid URI\n", | ||
| 123 | - URL, NULL, NULL); | ||
| 124 | - } else { | ||
| 125 | - if (uri->scheme == NULL) { | ||
| 126 | - xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE, | ||
| 127 | - "xmlns: URI %s is not absolute\n", | ||
| 128 | - URL, NULL, NULL); | ||
| 129 | - } | ||
| 130 | - xmlFreeURI(uri); | ||
| 131 | - } | ||
| 132 | - if (URL == ctxt->str_xml_ns) { | ||
| 133 | - if (attname != ctxt->str_xml) { | ||
| 134 | - xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, | ||
| 135 | - "xml namespace URI cannot be the default namespace\n", | ||
| 136 | - NULL, NULL, NULL); | ||
| 137 | - } | ||
| 138 | - goto skip_default_ns; | ||
| 139 | - } | ||
| 140 | - if ((len == 29) && | ||
| 141 | - (xmlStrEqual(URL, | ||
| 142 | - BAD_CAST "http://www.w3.org/2000/xmlns/"))) { | ||
| 143 | - xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, | ||
| 144 | - "reuse of the xmlns namespace name is forbidden\n", | ||
| 145 | - NULL, NULL, NULL); | ||
| 146 | - goto skip_default_ns; | ||
| 147 | - } | ||
| 148 | - } | ||
| 149 | - /* | ||
| 150 | - * check that it's not a defined namespace | ||
| 151 | - */ | ||
| 152 | - for (j = 1;j <= nbNs;j++) | ||
| 153 | - if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL) | ||
| 154 | - break; | ||
| 155 | - if (j <= nbNs) | ||
| 156 | - xmlErrAttributeDup(ctxt, NULL, attname); | ||
| 157 | - else | ||
| 158 | - if (nsPush(ctxt, NULL, URL) > 0) nbNs++; | ||
| 159 | -skip_default_ns: | ||
| 160 | - if ((attvalue != NULL) && (alloc != 0)) { | ||
| 161 | - xmlFree(attvalue); | ||
| 162 | - attvalue = NULL; | ||
| 163 | - } | ||
| 164 | - if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) | ||
| 165 | - break; | ||
| 166 | - if (!IS_BLANK_CH(RAW)) { | ||
| 167 | - xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, | ||
| 168 | - "attributes construct error\n"); | ||
| 169 | - break; | ||
| 170 | - } | ||
| 171 | - SKIP_BLANKS; | ||
| 172 | - if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) | ||
| 173 | - goto base_changed; | ||
| 174 | - continue; | ||
| 175 | - } | ||
| 176 | - if (aprefix == ctxt->str_xmlns) { | ||
| 177 | - const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len); | ||
| 178 | - xmlURIPtr uri; | ||
| 179 | - | ||
| 180 | - if (attname == ctxt->str_xml) { | ||
| 181 | - if (URL != ctxt->str_xml_ns) { | ||
| 182 | - xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, | ||
| 183 | - "xml namespace prefix mapped to wrong URI\n", | ||
| 184 | - NULL, NULL, NULL); | ||
| 185 | - } | ||
| 186 | - /* | ||
| 187 | - * Do not keep a namespace definition node | ||
| 188 | - */ | ||
| 189 | - goto skip_ns; | ||
| 190 | - } | ||
| 191 | + if ((attname == NULL) || (attvalue == NULL)) | ||
| 192 | + goto next_attr; | ||
| 193 | + if (len < 0) len = xmlStrlen(attvalue); | ||
| 194 | + | ||
| 195 | + if ((attname == ctxt->str_xmlns) && (aprefix == NULL)) { | ||
| 196 | + const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len); | ||
| 197 | + xmlURIPtr uri; | ||
| 198 | + | ||
| 199 | + if (URL == NULL) { | ||
| 200 | + xmlErrMemory(ctxt, "dictionary allocation failure"); | ||
| 201 | + if ((attvalue != NULL) && (alloc != 0)) | ||
| 202 | + xmlFree(attvalue); | ||
| 203 | + return(NULL); | ||
| 204 | + } | ||
| 205 | + if (*URL != 0) { | ||
| 206 | + uri = xmlParseURI((const char *) URL); | ||
| 207 | + if (uri == NULL) { | ||
| 208 | + xmlNsErr(ctxt, XML_WAR_NS_URI, | ||
| 209 | + "xmlns: '%s' is not a valid URI\n", | ||
| 210 | + URL, NULL, NULL); | ||
| 211 | + } else { | ||
| 212 | + if (uri->scheme == NULL) { | ||
| 213 | + xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE, | ||
| 214 | + "xmlns: URI %s is not absolute\n", | ||
| 215 | + URL, NULL, NULL); | ||
| 216 | + } | ||
| 217 | + xmlFreeURI(uri); | ||
| 218 | + } | ||
| 219 | if (URL == ctxt->str_xml_ns) { | ||
| 220 | - if (attname != ctxt->str_xml) { | ||
| 221 | - xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, | ||
| 222 | - "xml namespace URI mapped to wrong prefix\n", | ||
| 223 | - NULL, NULL, NULL); | ||
| 224 | - } | ||
| 225 | - goto skip_ns; | ||
| 226 | - } | ||
| 227 | - if (attname == ctxt->str_xmlns) { | ||
| 228 | - xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, | ||
| 229 | - "redefinition of the xmlns prefix is forbidden\n", | ||
| 230 | - NULL, NULL, NULL); | ||
| 231 | - goto skip_ns; | ||
| 232 | - } | ||
| 233 | - if ((len == 29) && | ||
| 234 | - (xmlStrEqual(URL, | ||
| 235 | - BAD_CAST "http://www.w3.org/2000/xmlns/"))) { | ||
| 236 | - xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, | ||
| 237 | - "reuse of the xmlns namespace name is forbidden\n", | ||
| 238 | - NULL, NULL, NULL); | ||
| 239 | - goto skip_ns; | ||
| 240 | - } | ||
| 241 | - if ((URL == NULL) || (URL[0] == 0)) { | ||
| 242 | - xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, | ||
| 243 | - "xmlns:%s: Empty XML namespace is not allowed\n", | ||
| 244 | - attname, NULL, NULL); | ||
| 245 | - goto skip_ns; | ||
| 246 | - } else { | ||
| 247 | - uri = xmlParseURI((const char *) URL); | ||
| 248 | - if (uri == NULL) { | ||
| 249 | - xmlNsErr(ctxt, XML_WAR_NS_URI, | ||
| 250 | - "xmlns:%s: '%s' is not a valid URI\n", | ||
| 251 | - attname, URL, NULL); | ||
| 252 | - } else { | ||
| 253 | - if ((ctxt->pedantic) && (uri->scheme == NULL)) { | ||
| 254 | - xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE, | ||
| 255 | - "xmlns:%s: URI %s is not absolute\n", | ||
| 256 | - attname, URL, NULL); | ||
| 257 | - } | ||
| 258 | - xmlFreeURI(uri); | ||
| 259 | - } | ||
| 260 | - } | ||
| 261 | - | ||
| 262 | - /* | ||
| 263 | - * check that it's not a defined namespace | ||
| 264 | - */ | ||
| 265 | - for (j = 1;j <= nbNs;j++) | ||
| 266 | - if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname) | ||
| 267 | - break; | ||
| 268 | - if (j <= nbNs) | ||
| 269 | - xmlErrAttributeDup(ctxt, aprefix, attname); | ||
| 270 | - else | ||
| 271 | - if (nsPush(ctxt, attname, URL) > 0) nbNs++; | ||
| 272 | -skip_ns: | ||
| 273 | - if ((attvalue != NULL) && (alloc != 0)) { | ||
| 274 | - xmlFree(attvalue); | ||
| 275 | - attvalue = NULL; | ||
| 276 | - } | ||
| 277 | - if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) | ||
| 278 | - break; | ||
| 279 | - if (!IS_BLANK_CH(RAW)) { | ||
| 280 | - xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, | ||
| 281 | - "attributes construct error\n"); | ||
| 282 | - break; | ||
| 283 | - } | ||
| 284 | - SKIP_BLANKS; | ||
| 285 | - if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) | ||
| 286 | - goto base_changed; | ||
| 287 | - continue; | ||
| 288 | - } | ||
| 289 | + if (attname != ctxt->str_xml) { | ||
| 290 | + xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, | ||
| 291 | + "xml namespace URI cannot be the default namespace\n", | ||
| 292 | + NULL, NULL, NULL); | ||
| 293 | + } | ||
| 294 | + goto next_attr; | ||
| 295 | + } | ||
| 296 | + if ((len == 29) && | ||
| 297 | + (xmlStrEqual(URL, | ||
| 298 | + BAD_CAST "http://www.w3.org/2000/xmlns/"))) { | ||
| 299 | + xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, | ||
| 300 | + "reuse of the xmlns namespace name is forbidden\n", | ||
| 301 | + NULL, NULL, NULL); | ||
| 302 | + goto next_attr; | ||
| 303 | + } | ||
| 304 | + } | ||
| 305 | + /* | ||
| 306 | + * check that it's not a defined namespace | ||
| 307 | + */ | ||
| 308 | + for (j = 1;j <= nbNs;j++) | ||
| 309 | + if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL) | ||
| 310 | + break; | ||
| 311 | + if (j <= nbNs) | ||
| 312 | + xmlErrAttributeDup(ctxt, NULL, attname); | ||
| 313 | + else | ||
| 314 | + if (nsPush(ctxt, NULL, URL) > 0) nbNs++; | ||
| 315 | + | ||
| 316 | + } else if (aprefix == ctxt->str_xmlns) { | ||
| 317 | + const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len); | ||
| 318 | + xmlURIPtr uri; | ||
| 319 | + | ||
| 320 | + if (attname == ctxt->str_xml) { | ||
| 321 | + if (URL != ctxt->str_xml_ns) { | ||
| 322 | + xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, | ||
| 323 | + "xml namespace prefix mapped to wrong URI\n", | ||
| 324 | + NULL, NULL, NULL); | ||
| 325 | + } | ||
| 326 | + /* | ||
| 327 | + * Do not keep a namespace definition node | ||
| 328 | + */ | ||
| 329 | + goto next_attr; | ||
| 330 | + } | ||
| 331 | + if (URL == ctxt->str_xml_ns) { | ||
| 332 | + if (attname != ctxt->str_xml) { | ||
| 333 | + xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, | ||
| 334 | + "xml namespace URI mapped to wrong prefix\n", | ||
| 335 | + NULL, NULL, NULL); | ||
| 336 | + } | ||
| 337 | + goto next_attr; | ||
| 338 | + } | ||
| 339 | + if (attname == ctxt->str_xmlns) { | ||
| 340 | + xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, | ||
| 341 | + "redefinition of the xmlns prefix is forbidden\n", | ||
| 342 | + NULL, NULL, NULL); | ||
| 343 | + goto next_attr; | ||
| 344 | + } | ||
| 345 | + if ((len == 29) && | ||
| 346 | + (xmlStrEqual(URL, | ||
| 347 | + BAD_CAST "http://www.w3.org/2000/xmlns/"))) { | ||
| 348 | + xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, | ||
| 349 | + "reuse of the xmlns namespace name is forbidden\n", | ||
| 350 | + NULL, NULL, NULL); | ||
| 351 | + goto next_attr; | ||
| 352 | + } | ||
| 353 | + if ((URL == NULL) || (URL[0] == 0)) { | ||
| 354 | + xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, | ||
| 355 | + "xmlns:%s: Empty XML namespace is not allowed\n", | ||
| 356 | + attname, NULL, NULL); | ||
| 357 | + goto next_attr; | ||
| 358 | + } else { | ||
| 359 | + uri = xmlParseURI((const char *) URL); | ||
| 360 | + if (uri == NULL) { | ||
| 361 | + xmlNsErr(ctxt, XML_WAR_NS_URI, | ||
| 362 | + "xmlns:%s: '%s' is not a valid URI\n", | ||
| 363 | + attname, URL, NULL); | ||
| 364 | + } else { | ||
| 365 | + if ((ctxt->pedantic) && (uri->scheme == NULL)) { | ||
| 366 | + xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE, | ||
| 367 | + "xmlns:%s: URI %s is not absolute\n", | ||
| 368 | + attname, URL, NULL); | ||
| 369 | + } | ||
| 370 | + xmlFreeURI(uri); | ||
| 371 | + } | ||
| 372 | + } | ||
| 373 | |||
| 374 | - /* | ||
| 375 | - * Add the pair to atts | ||
| 376 | - */ | ||
| 377 | - if ((atts == NULL) || (nbatts + 5 > maxatts)) { | ||
| 378 | - if (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) { | ||
| 379 | - if (attvalue[len] == 0) | ||
| 380 | - xmlFree(attvalue); | ||
| 381 | - goto failed; | ||
| 382 | - } | ||
| 383 | - maxatts = ctxt->maxatts; | ||
| 384 | - atts = ctxt->atts; | ||
| 385 | - } | ||
| 386 | - ctxt->attallocs[nratts++] = alloc; | ||
| 387 | - atts[nbatts++] = attname; | ||
| 388 | - atts[nbatts++] = aprefix; | ||
| 389 | - atts[nbatts++] = NULL; /* the URI will be fetched later */ | ||
| 390 | - atts[nbatts++] = attvalue; | ||
| 391 | - attvalue += len; | ||
| 392 | - atts[nbatts++] = attvalue; | ||
| 393 | - /* | ||
| 394 | - * tag if some deallocation is needed | ||
| 395 | - */ | ||
| 396 | - if (alloc != 0) attval = 1; | ||
| 397 | - } else { | ||
| 398 | - if ((attvalue != NULL) && (attvalue[len] == 0)) | ||
| 399 | - xmlFree(attvalue); | ||
| 400 | - } | ||
| 401 | + /* | ||
| 402 | + * check that it's not a defined namespace | ||
| 403 | + */ | ||
| 404 | + for (j = 1;j <= nbNs;j++) | ||
| 405 | + if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname) | ||
| 406 | + break; | ||
| 407 | + if (j <= nbNs) | ||
| 408 | + xmlErrAttributeDup(ctxt, aprefix, attname); | ||
| 409 | + else | ||
| 410 | + if (nsPush(ctxt, attname, URL) > 0) nbNs++; | ||
| 411 | + | ||
| 412 | + } else { | ||
| 413 | + /* | ||
| 414 | + * Add the pair to atts | ||
| 415 | + */ | ||
| 416 | + if ((atts == NULL) || (nbatts + 5 > maxatts)) { | ||
| 417 | + if (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) { | ||
| 418 | + goto next_attr; | ||
| 419 | + } | ||
| 420 | + maxatts = ctxt->maxatts; | ||
| 421 | + atts = ctxt->atts; | ||
| 422 | + } | ||
| 423 | + ctxt->attallocs[nratts++] = alloc; | ||
| 424 | + atts[nbatts++] = attname; | ||
| 425 | + atts[nbatts++] = aprefix; | ||
| 426 | + /* | ||
| 427 | + * The namespace URI field is used temporarily to point at the | ||
| 428 | + * base of the current input buffer for non-alloced attributes. | ||
| 429 | + * When the input buffer is reallocated, all the pointers become | ||
| 430 | + * invalid, but they can be reconstructed later. | ||
| 431 | + */ | ||
| 432 | + if (alloc) | ||
| 433 | + atts[nbatts++] = NULL; | ||
| 434 | + else | ||
| 435 | + atts[nbatts++] = ctxt->input->base; | ||
| 436 | + atts[nbatts++] = attvalue; | ||
| 437 | + attvalue += len; | ||
| 438 | + atts[nbatts++] = attvalue; | ||
| 439 | + /* | ||
| 440 | + * tag if some deallocation is needed | ||
| 441 | + */ | ||
| 442 | + if (alloc != 0) attval = 1; | ||
| 443 | + attvalue = NULL; /* moved into atts */ | ||
| 444 | + } | ||
| 445 | |||
| 446 | -failed: | ||
| 447 | +next_attr: | ||
| 448 | + if ((attvalue != NULL) && (alloc != 0)) { | ||
| 449 | + xmlFree(attvalue); | ||
| 450 | + attvalue = NULL; | ||
| 451 | + } | ||
| 452 | |||
| 453 | GROW | ||
| 454 | if (ctxt->instate == XML_PARSER_EOF) | ||
| 455 | break; | ||
| 456 | - if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) | ||
| 457 | - goto base_changed; | ||
| 458 | if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) | ||
| 459 | break; | ||
| 460 | if (!IS_BLANK_CH(RAW)) { | ||
| 461 | @@ -9646,8 +9610,20 @@ failed: | ||
| 462 | break; | ||
| 463 | } | ||
| 464 | GROW; | ||
| 465 | - if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) | ||
| 466 | - goto base_changed; | ||
| 467 | + } | ||
| 468 | + | ||
| 469 | + /* Reconstruct attribute value pointers. */ | ||
| 470 | + for (i = 0, j = 0; j < nratts; i += 5, j++) { | ||
| 471 | + if (atts[i+2] != NULL) { | ||
| 472 | + /* | ||
| 473 | + * Arithmetic on dangling pointers is technically undefined | ||
| 474 | + * behavior, but well... | ||
| 475 | + */ | ||
| 476 | + ptrdiff_t offset = ctxt->input->base - atts[i+2]; | ||
| 477 | + atts[i+2] = NULL; /* Reset repurposed namespace URI */ | ||
| 478 | + atts[i+3] += offset; /* value */ | ||
| 479 | + atts[i+4] += offset; /* valuend */ | ||
| 480 | + } | ||
| 481 | } | ||
| 482 | |||
| 483 | /* | ||
| 484 | @@ -9804,34 +9780,6 @@ failed: | ||
| 485 | } | ||
| 486 | |||
| 487 | return(localname); | ||
| 488 | - | ||
| 489 | -base_changed: | ||
| 490 | - /* | ||
| 491 | - * the attribute strings are valid iif the base didn't changed | ||
| 492 | - */ | ||
| 493 | - if (attval != 0) { | ||
| 494 | - for (i = 3,j = 0; j < nratts;i += 5,j++) | ||
| 495 | - if ((ctxt->attallocs[j] != 0) && (atts[i] != NULL)) | ||
| 496 | - xmlFree((xmlChar *) atts[i]); | ||
| 497 | - } | ||
| 498 | - | ||
| 499 | - /* | ||
| 500 | - * We can't switch from one entity to another in the middle | ||
| 501 | - * of a start tag | ||
| 502 | - */ | ||
| 503 | - if (inputNr != ctxt->inputNr) { | ||
| 504 | - xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY, | ||
| 505 | - "Start tag doesn't start and stop in the same entity\n"); | ||
| 506 | - return(NULL); | ||
| 507 | - } | ||
| 508 | - | ||
| 509 | - ctxt->input->cur = ctxt->input->base + cur; | ||
| 510 | - ctxt->input->line = oldline; | ||
| 511 | - ctxt->input->col = oldcol; | ||
| 512 | - if (ctxt->wellFormed == 1) { | ||
| 513 | - goto reparse; | ||
| 514 | - } | ||
| 515 | - return(NULL); | ||
| 516 | } | ||
| 517 | |||
| 518 | /** | ||
| 519 | diff --git a/result/errors/759398.xml.err b/result/errors/759398.xml.err | ||
| 520 | index e08d9bf..f6036a3 100644 | ||
| 521 | --- a/result/errors/759398.xml.err | ||
| 522 | +++ b/result/errors/759398.xml.err | ||
| 523 | @@ -1,9 +1,12 @@ | ||
| 524 | ./test/errors/759398.xml:210: parser error : StartTag: invalid element name | ||
| 525 | need to worry about parsers whi<! don't expand PErefs finding | ||
| 526 | ^ | ||
| 527 | -./test/errors/759398.xml:309: parser error : Opening and ending tag mismatch: spec line 50 and termdef | ||
| 528 | +./test/errors/759398.xml:309: parser error : Opening and ending tag mismatch: №№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№m line 308 and termdef | ||
| 529 | and provide access to their content and structure.</termdef> <termdef | ||
| 530 | ^ | ||
| 531 | -./test/errors/759398.xml:309: parser error : Extra content at the end of the document | ||
| 532 | -and provide access to their content and structure.</termdef> <termdef | ||
| 533 | - ^ | ||
| 534 | +./test/errors/759398.xml:314: parser error : Opening and ending tag mismatch: spec line 50 and p | ||
| 535 | +data and the information it must provide to the application.</p> | ||
| 536 | + ^ | ||
| 537 | +./test/errors/759398.xml:316: parser error : Extra content at the end of the document | ||
| 538 | +<div2 id='sec-origin-goals'> | ||
| 539 | +^ | ||
| 540 | diff --git a/result/errors/attr1.xml.err b/result/errors/attr1.xml.err | ||
| 541 | index 4f08538..c4c4fc8 100644 | ||
| 542 | --- a/result/errors/attr1.xml.err | ||
| 543 | +++ b/result/errors/attr1.xml.err | ||
| 544 | @@ -1,6 +1,9 @@ | ||
| 545 | ./test/errors/attr1.xml:2: parser error : AttValue: ' expected | ||
| 546 | |||
| 547 | ^ | ||
| 548 | -./test/errors/attr1.xml:1: parser error : Extra content at the end of the document | ||
| 549 | -<foo foo="oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | ||
| 550 | - ^ | ||
| 551 | +./test/errors/attr1.xml:2: parser error : attributes construct error | ||
| 552 | + | ||
| 553 | +^ | ||
| 554 | +./test/errors/attr1.xml:2: parser error : Couldn't find end of Start Tag foo line 1 | ||
| 555 | + | ||
| 556 | +^ | ||
| 557 | diff --git a/result/errors/attr2.xml.err b/result/errors/attr2.xml.err | ||
| 558 | index c8a9c7d..77e342e 100644 | ||
| 559 | --- a/result/errors/attr2.xml.err | ||
| 560 | +++ b/result/errors/attr2.xml.err | ||
| 561 | @@ -1,6 +1,9 @@ | ||
| 562 | ./test/errors/attr2.xml:2: parser error : AttValue: ' expected | ||
| 563 | |||
| 564 | ^ | ||
| 565 | -./test/errors/attr2.xml:1: parser error : Extra content at the end of the document | ||
| 566 | -<foo foo=">ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | ||
| 567 | - ^ | ||
| 568 | +./test/errors/attr2.xml:2: parser error : attributes construct error | ||
| 569 | + | ||
| 570 | +^ | ||
| 571 | +./test/errors/attr2.xml:2: parser error : Couldn't find end of Start Tag foo line 1 | ||
| 572 | + | ||
| 573 | +^ | ||
| 574 | diff --git a/result/errors/name2.xml.err b/result/errors/name2.xml.err | ||
| 575 | index a6649a1..8a6acee 100644 | ||
| 576 | --- a/result/errors/name2.xml.err | ||
| 577 | +++ b/result/errors/name2.xml.err | ||
| 578 | @@ -1,6 +1,9 @@ | ||
| 579 | ./test/errors/name2.xml:2: parser error : Specification mandate value for attribute foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | ||
| 580 | |||
| 581 | ^ | ||
| 582 | -./test/errors/name2.xml:1: parser error : Extra content at the end of the document | ||
| 583 | -<foo foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | ||
| 584 | - ^ | ||
| 585 | +./test/errors/name2.xml:2: parser error : attributes construct error | ||
| 586 | + | ||
| 587 | +^ | ||
| 588 | +./test/errors/name2.xml:2: parser error : Couldn't find end of Start Tag foo line 1 | ||
| 589 | + | ||
| 590 | +^ | ||
diff --git a/meta/recipes-core/libxml/libxml2_2.9.4.bb b/meta/recipes-core/libxml/libxml2_2.9.4.bb index 4f60781d22..0577ad6509 100644 --- a/meta/recipes-core/libxml/libxml2_2.9.4.bb +++ b/meta/recipes-core/libxml/libxml2_2.9.4.bb | |||
| @@ -23,6 +23,7 @@ SRC_URI = "ftp://xmlsoft.org/libxml2/libxml2-${PV}.tar.gz;name=libtar \ | |||
| 23 | file://libxml2-CVE-2016-5131.patch \ | 23 | file://libxml2-CVE-2016-5131.patch \ |
| 24 | file://libxml2-CVE-2016-4658.patch \ | 24 | file://libxml2-CVE-2016-4658.patch \ |
| 25 | file://libxml2-fix_NULL_pointer_derefs.patch \ | 25 | file://libxml2-fix_NULL_pointer_derefs.patch \ |
| 26 | file://libxml2-fix_and_simplify_xmlParseStartTag2.patch \ | ||
| 26 | file://CVE-2016-9318.patch \ | 27 | file://CVE-2016-9318.patch \ |
| 27 | file://0001-Make-ptest-run-the-python-tests-if-python-is-enabled.patch \ | 28 | file://0001-Make-ptest-run-the-python-tests-if-python-is-enabled.patch \ |
| 28 | " | 29 | " |
