Skip to content

Commit ccb8d2f

Browse files
Add _Py_HashSecret_t.expat.hashsalt16 instead
1 parent 03794ce commit ccb8d2f

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

Include/internal/pycore_pyhash.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ _Py_HashPointerRaw(const void *ptr)
2727
* pppppppp ssssssss ........ fnv -- two Py_hash_t
2828
* k0k0k0k0 k1k1k1k1 ........ siphash -- two uint64_t
2929
* ........ ........ ssssssss djbx33a -- 16 bytes padding + one Py_hash_t
30-
* ........ ........ eeeeeeee pyexpat XML hash salt
30+
* eeeeeeee eeeeeeee eeeeeeee pyexpat XML hash salt
3131
*
3232
* memory layout on 32 bit systems
3333
* cccccccc cccccccc cccccccc uc
3434
* ppppssss ........ ........ fnv -- two Py_hash_t
3535
* k0k0k0k0 k1k1k1k1 ........ siphash -- two uint64_t (*)
3636
* ........ ........ ssss.... djbx33a -- 16 bytes padding + one Py_hash_t
37-
* ........ ........ eeee.... pyexpat XML hash salt
37+
* eeeeeeee eeeeeeee eeee.... pyexpat XML hash salt
3838
*
3939
* (*) The siphash member may not be available on 32 bit platforms without
4040
* an unsigned int64 data type.
@@ -58,7 +58,9 @@ typedef union {
5858
Py_hash_t suffix;
5959
} djbx33a;
6060
struct {
61-
unsigned char padding[16];
61+
/* 16 bytes for XML_SetHashSalt16Bytes */
62+
uint8_t hashsalt16[16];
63+
/* 4/8 bytes for legacy XML_SetHashSalt */
6264
Py_hash_t hashsalt;
6365
} expat;
6466
} _Py_HashSecret_t;

Modules/_elementtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3738,7 +3738,7 @@ _elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *target,
37383738
// Prefer 16-byte entropy, only expat >= 2.8.0. See gh-149018
37393739
if (EXPAT(st, SetHashSalt16Bytes) != NULL) {
37403740
EXPAT(st, SetHashSalt16Bytes)(self->parser,
3741-
(const uint8_t *)_Py_HashSecret.uc);
3741+
_Py_HashSecret.expat.hashsalt16);
37423742
}
37433743
else if (EXPAT(st, SetHashSalt) != NULL) {
37443744
EXPAT(st, SetHashSalt)(self->parser,

Modules/pyexpat.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,8 +1535,7 @@ newxmlparseobject(pyexpat_state *state, const char *encoding,
15351535
}
15361536
#if XML_COMBINED_VERSION >= 20800
15371537
/* This feature was added upstream in libexpat 2.8.0. */
1538-
XML_SetHashSalt16Bytes(self->itself,
1539-
(const uint8_t *)_Py_HashSecret.uc);
1538+
XML_SetHashSalt16Bytes(self->itself, _Py_HashSecret.expat.hashsalt16);
15401539
#elif XML_COMBINED_VERSION >= 20100
15411540
/* This feature was added upstream in libexpat 2.1.0. */
15421541
XML_SetHashSalt(self->itself,

0 commit comments

Comments
 (0)