diff options
author | Mark Dickinson <mdickinson@enthought.com> | 2011-09-25 14:34:32 (GMT) |
---|---|---|
committer | Mark Dickinson <mdickinson@enthought.com> | 2011-09-25 14:34:32 (GMT) |
commit | c7d93b761413834e0ac39f5fc648565a2843121f (patch) | |
tree | 0bcb66dfcb476fb49a59ce019943f293f003dbc0 /Modules | |
parent | 50203a69b344e80be5000fe87aafad09e84cde85 (diff) | |
download | cpython-c7d93b761413834e0ac39f5fc648565a2843121f.zip cpython-c7d93b761413834e0ac39f5fc648565a2843121f.tar.gz cpython-c7d93b761413834e0ac39f5fc648565a2843121f.tar.bz2 |
Issue #1621: Fix undefined behaviour from signed overflow in datetime module hashes, array and list iterations, and get_integer (stringlib/string_format.h)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_datetimemodule.c | 8 | ||||
-rw-r--r-- | Modules/arraymodule.c | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 718dfe2..26e0ed0 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -2746,13 +2746,13 @@ static Py_hash_t generic_hash(unsigned char *data, int len) { register unsigned char *p; - register Py_hash_t x; + register Py_uhash_t x; p = (unsigned char *) data; - x = *p << 7; + x = (Py_uhash_t)*p << 7; while (--len >= 0) - x = (1000003*x) ^ *p++; - x ^= len; + x = (1000003U*x) ^ (Py_uhash_t)*p++; + x ^= (Py_uhash_t)len; if (x == -1) x = -2; diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 5748a3c..8806bd5 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -2351,7 +2351,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) self->ob_item + (cur + 1) * itemsize, lim * itemsize); } - cur = start + slicelength * step; + cur = start + (size_t)slicelength * step; if (cur < (size_t)Py_SIZE(self)) { memmove(self->ob_item + (cur-slicelength) * itemsize, self->ob_item + cur * itemsize, |