changeset: 79532:906ae6485cb8 branch: 3.3 parent: 79529:152d85b2da3a user: Mark Dickinson date: Sat Oct 06 18:50:02 2012 +0100 files: Objects/longobject.c description: Issue #16096: Fix signed overflow in Objects/longobject.c. Thanks Serhiy Storchaka. diff -r 152d85b2da3a -r 906ae6485cb8 Objects/longobject.c --- a/Objects/longobject.c Sat Oct 06 18:04:49 2012 +0100 +++ b/Objects/longobject.c Sat Oct 06 18:50:02 2012 +0100 @@ -668,10 +668,9 @@ assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0); if (ndigits> 0) { digit msd = v->ob_digit[ndigits - 1]; - - result = (ndigits - 1) * PyLong_SHIFT; - if (result / PyLong_SHIFT != (size_t)(ndigits - 1)) + if ((size_t)(ndigits - 1)> PY_SIZE_MAX / (size_t)PyLong_SHIFT) goto Overflow; + result = (size_t)(ndigits - 1) * (size_t)PyLong_SHIFT; do { ++result; if (result == 0)

AltStyle によって変換されたページ (->オリジナル) /