summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2018-08-25 01:08:50 (GMT)
committerGitHub <noreply@github.com>2018-08-25 01:08:50 (GMT)
commit76be0fffff8b7dbe649ad4821144461800ffb0d0 (patch)
tree9ef8e6646a08ddf8ae63a2600945b3c47f3ab79b /Modules
parenteb746dbae8b320758ee08f811316d7f283435cc0 (diff)
downloadcpython-76be0fffff8b7dbe649ad4821144461800ffb0d0.zip
cpython-76be0fffff8b7dbe649ad4821144461800ffb0d0.tar.gz
cpython-76be0fffff8b7dbe649ad4821144461800ffb0d0.tar.bz2
bpo-13312: Avoid int underflow in time year. (GH-8912)
Avoids an integer underflow in the time module's year handling code.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/timemodule.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 998216c..dbe2fba 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -551,6 +551,12 @@ gettmarg(PyObject *args, struct tm *p, const char *format)
&p->tm_hour, &p->tm_min, &p->tm_sec,
&p->tm_wday, &p->tm_yday, &p->tm_isdst))
return 0;
+
+ if (y < INT_MIN + 1900) {
+ PyErr_SetString(PyExc_OverflowError, "year out of range");
+ return 0;
+ }
+
p->tm_year = y - 1900;
p->tm_mon--;
p->tm_wday = (p->tm_wday + 1) % 7;