From: Alexander Belopolsky Date: Mon, 25 Jul 2016 17:54:51 +0000 (-0400) Subject: Issue 24773: Added a time_t overflow check. X-Git-Tag: v3.6.0a4~115 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8e1d3a2d41b6f064b60e69b3432ed3a2692bd19f;p=thirdparty%2FPython%2Fcpython.git Issue 24773: Added a time_t overflow check. --- diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 1157859ae3f7..7dfb0c2684bc 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -4207,7 +4207,14 @@ static PY_LONG_LONG local(PY_LONG_LONG u) { struct tm local_time; - time_t t = u - epoch; + time_t t; + u -= epoch; + t = u; + if (t != u) { + PyErr_SetString(PyExc_OverflowError, + "timestamp out of range for platform time_t"); + return -1; + } /* XXX: add bounds checking */ if (localtime_r(&t, &local_time) == NULL) { PyErr_SetFromErrno(PyExc_OSError);