mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-13312: Avoid int underflow in time year. (GH-8912)
Avoids an integer underflow in the time module's year handling code.
This commit is contained in:
parent
eb746dbae8
commit
76be0fffff
3 changed files with 13 additions and 6 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue