Commit | Line | Data |
---|---|---|
90aeaee8 MB |
1 | Fix CVE-2018-14647: |
2 | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-14647 | |
3 | https://bugs.python.org/issue34623 | |
4 | ||
5 | Taken from upstream: | |
6 | https://github.com/python/cpython/commit/f7666e828cc3d5873136473ea36ba2013d624fa1 | |
7 | ||
8 | diff --git Include/pyexpat.h Include/pyexpat.h | |
9 | index 44259bf6d7..07020b5dc9 100644 | |
10 | --- Include/pyexpat.h | |
11 | +++ Include/pyexpat.h | |
12 | @@ -3,7 +3,7 @@ | |
13 | ||
14 | /* note: you must import expat.h before importing this module! */ | |
15 | ||
16 | -#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.0" | |
17 | +#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.1" | |
18 | #define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI" | |
19 | ||
20 | struct PyExpat_CAPI | |
21 | @@ -48,6 +48,8 @@ struct PyExpat_CAPI | |
22 | enum XML_Status (*SetEncoding)(XML_Parser parser, const XML_Char *encoding); | |
23 | int (*DefaultUnknownEncodingHandler)( | |
24 | void *encodingHandlerData, const XML_Char *name, XML_Encoding *info); | |
25 | + /* might be none for expat < 2.1.0 */ | |
26 | + int (*SetHashSalt)(XML_Parser parser, unsigned long hash_salt); | |
27 | /* always add new stuff to the end! */ | |
28 | }; | |
29 | ||
30 | diff --git Modules/_elementtree.c Modules/_elementtree.c | |
31 | index 707ab2912b..53f05f937f 100644 | |
32 | --- Modules/_elementtree.c | |
33 | +++ Modules/_elementtree.c | |
34 | @@ -3261,6 +3261,11 @@ _elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *html, | |
35 | PyErr_NoMemory(); | |
36 | return -1; | |
37 | } | |
38 | + /* expat < 2.1.0 has no XML_SetHashSalt() */ | |
39 | + if (EXPAT(SetHashSalt) != NULL) { | |
40 | + EXPAT(SetHashSalt)(self->parser, | |
41 | + (unsigned long)_Py_HashSecret.expat.hashsalt); | |
42 | + } | |
43 | ||
44 | if (target) { | |
45 | Py_INCREF(target); | |
46 | diff --git Modules/pyexpat.c Modules/pyexpat.c | |
47 | index 47c3e86c20..aa21d93c11 100644 | |
48 | --- Modules/pyexpat.c | |
49 | +++ Modules/pyexpat.c | |
50 | @@ -1887,6 +1887,11 @@ MODULE_INITFUNC(void) | |
51 | capi.SetStartDoctypeDeclHandler = XML_SetStartDoctypeDeclHandler; | |
52 | capi.SetEncoding = XML_SetEncoding; | |
53 | capi.DefaultUnknownEncodingHandler = PyUnknownEncodingHandler; | |
54 | +#if XML_COMBINED_VERSION >= 20100 | |
55 | + capi.SetHashSalt = XML_SetHashSalt; | |
56 | +#else | |
57 | + capi.SetHashSalt = NULL; | |
58 | +#endif | |
59 | ||
60 | /* export using capsule */ | |
61 | capi_object = PyCapsule_New(&capi, PyExpat_CAPSULE_NAME, NULL); |