diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-04-20 17:06:21 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2018-04-20 17:06:21 (GMT) |
commit | 392520bd78cd18639a27e5d2803c2e1c2bd593a8 (patch) | |
tree | 60e7657a15f43032eb28c68200fcf8c1c3f9ef65 /Misc | |
parent | 18cd82815b9bdeabc5ac03aa7f58102109ccf368 (diff) | |
download | cpython-392520bd78cd18639a27e5d2803c2e1c2bd593a8.zip cpython-392520bd78cd18639a27e5d2803c2e1c2bd593a8.tar.gz cpython-392520bd78cd18639a27e5d2803c2e1c2bd593a8.tar.bz2 |
bpo-33312: Fix clang ubsan out of bounds warnings in dict. (GH-6537) (GH-6543)
Fix clang ubsan (undefined behavior sanitizer) warnings in dictobject.c by
adjusting how the internal struct _dictkeysobject shared keys structure is
declared.
This remains ABI compatible. We get rid of the union at the end of the
struct being used for conveinence to avoid typecasting in favor of char[]
variable length array at the end of a struct. This is known to clang to be
used for variable sized objects and will not cause an undefined behavior
problem. Similarly, char arrays do not have strict aliasing undefined
behavior when cast.
PEP-007 does not currently list variable length arrays (VLAs) as allowed
in our subset of C99. If this turns out to be a problem, the fix to this is
to change the char `dk_indices[]` into `dk_indices[1]` and restore the
three size computation subtractions this change removes:
`- Py_MEMBER_SIZE(PyDictKeysObject, dk_indices)`
If this works as is I'll make a separate PR to update PEP-007.
(cherry picked from commit 397f1b28c4a12e3b3ed59a89599eabc457412649)
Diffstat (limited to 'Misc')
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2018-04-19-08-30-07.bpo-33312.mDe2iL.rst | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-04-19-08-30-07.bpo-33312.mDe2iL.rst b/Misc/NEWS.d/next/Core and Builtins/2018-04-19-08-30-07.bpo-33312.mDe2iL.rst new file mode 100644 index 0000000..40b51b9 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2018-04-19-08-30-07.bpo-33312.mDe2iL.rst @@ -0,0 +1,3 @@ +Fixed clang ubsan (undefined behavior sanitizer) warnings in dictobject.c by +adjusting how the internal struct _dictkeysobject shared keys structure is +declared. |