diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-01-06 17:45:00 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-01-06 17:45:27 +0100 |
commit | d81dbb6dee272bd18c7a1d3e0dbe429b04187f8b (patch) | |
tree | a0073ed3f3fdd028217301f56147e5b2e6f2386b | |
parent | 901091f47a661571a7fb935bd5ccec34e37ad688 (diff) |
external/libxml2: Work around -fsanitize=bounds
Change-Id: I57d30410640fa1b7e1768136b1802546b2b7253f
-rw-r--r-- | external/libxml2/UnpackedTarball_xml2.mk | 1 | ||||
-rw-r--r-- | external/libxml2/ubsan.patch.0 | 84 |
2 files changed, 85 insertions, 0 deletions
diff --git a/external/libxml2/UnpackedTarball_xml2.mk b/external/libxml2/UnpackedTarball_xml2.mk index 9c53b1fac6d5..beed009c414a 100644 --- a/external/libxml2/UnpackedTarball_xml2.mk +++ b/external/libxml2/UnpackedTarball_xml2.mk @@ -18,6 +18,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,xml2,\ external/libxml2/libxml2-vc10.patch \ $(if $(filter ANDROID,$(OS)),external/libxml2/libxml2-android.patch) \ external/libxml2/libxml2-icu.patch.0 \ + external/libxml2/ubsan.patch.0 \ )) # vim: set noet sw=4 ts=4: diff --git a/external/libxml2/ubsan.patch.0 b/external/libxml2/ubsan.patch.0 new file mode 100644 index 000000000000..cebacc470cc4 --- /dev/null +++ b/external/libxml2/ubsan.patch.0 @@ -0,0 +1,84 @@ +--- parser.c ++++ parser.c +@@ -1052,7 +1052,7 @@ + struct _xmlDefAttrs { + int nbAttrs; /* number of defaulted attributes on that element */ + int maxAttrs; /* the size of the array */ +- const xmlChar *values[5]; /* array of localname/prefix/values/external */ ++ const xmlChar *values[1][5]; /* array of localname/prefix/values/external */ + }; + + /** +@@ -1244,17 +1244,17 @@ + prefix = xmlDictLookup(ctxt->dict, fullattr, len); + } + +- defaults->values[5 * defaults->nbAttrs] = name; +- defaults->values[5 * defaults->nbAttrs + 1] = prefix; ++ defaults->values[defaults->nbAttrs][0] = name; ++ defaults->values[defaults->nbAttrs][1] = prefix; + /* intern the string and precompute the end */ + len = xmlStrlen(value); + value = xmlDictLookup(ctxt->dict, value, len); +- defaults->values[5 * defaults->nbAttrs + 2] = value; +- defaults->values[5 * defaults->nbAttrs + 3] = value + len; ++ defaults->values[defaults->nbAttrs][2] = value; ++ defaults->values[defaults->nbAttrs][3] = value + len; + if (ctxt->external) +- defaults->values[5 * defaults->nbAttrs + 4] = BAD_CAST "external"; ++ defaults->values[defaults->nbAttrs][4] = BAD_CAST "external"; + else +- defaults->values[5 * defaults->nbAttrs + 4] = NULL; ++ defaults->values[defaults->nbAttrs][4] = NULL; + defaults->nbAttrs++; + + return; +@@ -9474,8 +9474,8 @@ + defaults = xmlHashLookup2(ctxt->attsDefault, localname, prefix); + if (defaults != NULL) { + for (i = 0;i < defaults->nbAttrs;i++) { +- attname = defaults->values[5 * i]; +- aprefix = defaults->values[5 * i + 1]; ++ attname = defaults->values[i][0]; ++ aprefix = defaults->values[i][1]; + + /* + * special work for namespaces defaulted defs +@@ -9490,9 +9490,9 @@ + if (j <= nbNs) continue; + + nsname = xmlGetNamespace(ctxt, NULL); +- if (nsname != defaults->values[5 * i + 2]) { ++ if (nsname != defaults->values[i][2]) { + if (nsPush(ctxt, NULL, +- defaults->values[5 * i + 2]) > 0) ++ defaults->values[i][2]) > 0) + nbNs++; + } + } else if (aprefix == ctxt->str_xmlns) { +@@ -9505,9 +9505,9 @@ + if (j <= nbNs) continue; + + nsname = xmlGetNamespace(ctxt, attname); +- if (nsname != defaults->values[2]) { ++ if (nsname != defaults->values[0][2]) { + if (nsPush(ctxt, attname, +- defaults->values[5 * i + 2]) > 0) ++ defaults->values[i][2]) > 0) + nbNs++; + } + } else { +@@ -9533,10 +9533,10 @@ + atts[nbatts++] = NULL; + else + atts[nbatts++] = xmlGetNamespace(ctxt, aprefix); +- atts[nbatts++] = defaults->values[5 * i + 2]; +- atts[nbatts++] = defaults->values[5 * i + 3]; ++ atts[nbatts++] = defaults->values[i][2]; ++ atts[nbatts++] = defaults->values[i][3]; + if ((ctxt->standalone == 1) && +- (defaults->values[5 * i + 4] != NULL)) { ++ (defaults->values[i][4] != NULL)) { + xmlValidityError(ctxt, XML_DTD_STANDALONE_DEFAULTED, + "standalone: attribute %s on %s defaulted from external subset\n", + attname, localname); |