gnu: python-babel: Update to 2.7.0.
[guix.git] / gnu / packages / patches / python2-CVE-2018-14647.patch
blob6226b06aca017288ab84bbba546e1e4b7826e074
1 Fix CVE-2018-14647:
2 https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-14647
3 https://bugs.python.org/issue34623
5 Taken from upstream:
6 https://github.com/python/cpython/commit/18b20bad75b4ff0486940fba4ec680e96e70f3a2
8 diff --git a/Include/pyexpat.h b/Include/pyexpat.h
9 index 5340ef5fa3..3fc5fa54da 100644
10 --- a/Include/pyexpat.h
11 +++ b/Include/pyexpat.h
12 @@ -3,7 +3,7 @@
14 /* note: you must import expat.h before importing this module! */
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"
20 struct PyExpat_CAPI
21 @@ -43,6 +43,8 @@ struct PyExpat_CAPI
22 XML_Parser parser, XML_UnknownEncodingHandler handler,
23 void *encodingHandlerData);
24 void (*SetUserData)(XML_Parser parser, void *userData);
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! */
30 diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
31 index f7f992dd3a..b38e0ab329 100644
32 --- a/Modules/_elementtree.c
33 +++ b/Modules/_elementtree.c
34 @@ -2574,6 +2574,11 @@ xmlparser(PyObject* self_, PyObject* args, PyObject* kw)
35 PyErr_NoMemory();
36 return NULL;
38 + /* expat < 2.1.0 has no XML_SetHashSalt() */
39 + if (EXPAT(SetHashSalt) != NULL) {
40 + EXPAT(SetHashSalt)(self->parser,
41 + (unsigned long)_Py_HashSecret.prefix);
42 + }
44 ALLOC(sizeof(XMLParserObject), "create expatparser");
46 diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
47 index 2b4d31293c..1f8c0d70a5 100644
48 --- a/Modules/pyexpat.c
49 +++ b/Modules/pyexpat.c
50 @@ -2042,6 +2042,11 @@ MODULE_INITFUNC(void)
51 capi.SetProcessingInstructionHandler = XML_SetProcessingInstructionHandler;
52 capi.SetUnknownEncodingHandler = XML_SetUnknownEncodingHandler;
53 capi.SetUserData = XML_SetUserData;
54 +#if XML_COMBINED_VERSION >= 20100
55 + capi.SetHashSalt = XML_SetHashSalt;
56 +#else
57 + capi.SetHashSalt = NULL;
58 +#endif
60 /* export using capsule */
61 capi_object = PyCapsule_New(&capi, PyExpat_CAPSULE_NAME, NULL);