]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue 24773: Added a time_t overflow check.
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>
Mon, 25 Jul 2016 17:54:51 +0000 (13:54 -0400)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>
Mon, 25 Jul 2016 17:54:51 +0000 (13:54 -0400)
Modules/_datetimemodule.c

index 1157859ae3f77156532308fe42418cb78091a7bd..7dfb0c2684bc7fb749f0568aa8ae907869d26f45 100644 (file)
@@ -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);