[Python-checkins] cpython: Issue 24773: Added a time_t overflow check.

alexander.belopolsky python-checkins at python.org
Mon Jul 25 13:54:53 EDT 2016


https://hg.python.org/cpython/rev/8cc06070e98b
changeset: 102451:8cc06070e98b
user: Alexander Belopolsky <alexander.belopolsky at gmail.com>
date: Mon Jul 25 13:54:51 2016 -0400
summary:
 Issue 24773: Added a time_t overflow check.
files:
 Modules/_datetimemodule.c | 9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -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);
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /