diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2016-07-25 17:54:51 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2016-07-25 17:54:51 (GMT) |
commit | 8e1d3a2d41b6f064b60e69b3432ed3a2692bd19f (patch) | |
tree | e19fbacd6c5341ca965c0f6bbe8518c23201fd57 /Modules/_datetimemodule.c | |
parent | 43b17134e93872216621985677a286019b76aac7 (diff) | |
download | cpython-8e1d3a2d41b6f064b60e69b3432ed3a2692bd19f.zip cpython-8e1d3a2d41b6f064b60e69b3432ed3a2692bd19f.tar.gz cpython-8e1d3a2d41b6f064b60e69b3432ed3a2692bd19f.tar.bz2 |
Issue 24773: Added a time_t overflow check.
Diffstat (limited to 'Modules/_datetimemodule.c')
-rw-r--r-- | Modules/_datetimemodule.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 1157859..7dfb0c2 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); |