summaryrefslogtreecommitdiff
path: root/Modules/_elementtree.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2018-09-18 14:38:58 +0200
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-09-18 05:38:58 -0700
commitcb5778f00ce48631c7140f33ba242496aaf7102b (patch)
tree9905106a1ee7ce94d9fa93b6ac395634c2f24c2f /Modules/_elementtree.c
parent0185f34ddcf07b78feb6ac666fbfd4615d26b028 (diff)
downloadcpython-git-cb5778f00ce48631c7140f33ba242496aaf7102b.tar.gz
bpo-34623: Use XML_SetHashSalt in _elementtree (GH-9146)
The C accelerated _elementtree module now initializes hash randomization salt from _Py_HashSecret instead of libexpat's default CPRNG. Signed-off-by: Christian Heimes <christian@python.org> https://bugs.python.org/issue34623
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r--Modules/_elementtree.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 02781d5d89..bba6873887 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -3272,6 +3272,11 @@ _elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *target,
PyErr_NoMemory();
return -1;
}
+ /* expat < 2.1.0 has no XML_SetHashSalt() */
+ if (EXPAT(SetHashSalt) != NULL) {
+ EXPAT(SetHashSalt)(self->parser,
+ (unsigned long)_Py_HashSecret.expat.hashsalt);
+ }
if (target) {
Py_INCREF(target);