changeset: 102451:8cc06070e98b user: Alexander Belopolsky date: Mon Jul 25 13:54:51 2016 -0400 files: Modules/_datetimemodule.c description: Issue 24773: Added a time_t overflow check. diff -r 5c76f787e695 -r 8cc06070e98b Modules/_datetimemodule.c --- a/Modules/_datetimemodule.c Mon Jul 25 00:31:54 2016 -0400 +++ b/Modules/_datetimemodule.c Mon Jul 25 13:54:51 2016 -0400 @@ -4207,7 +4207,14 @@ 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);