summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2016-07-25 13:54:51 -0400
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2016-07-25 13:54:51 -0400
commit959856e054e50bc4a05532f0678b2bc3ee867f97 (patch)
tree17e50d05f5bc2a8c3173480869ba0f234dff05d4 /Modules
parent17f0e27fccb38529bc077b187da9c3829d0a3f3d (diff)
downloadcpython-959856e054e50bc4a05532f0678b2bc3ee867f97.tar.gz
Issue 24773: Added a time_t overflow check.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_datetimemodule.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 1157859ae3..7dfb0c2684 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);