mirror of
https://github.com/python/cpython.git
synced 2025-08-16 06:40:56 +00:00
Issue #11235: Fix OverflowError when trying to import a source file whose modification time doesn't fit in a 32-bit timestamp.
This commit is contained in:
parent
dfdc46f274
commit
d1c818a9c0
3 changed files with 20 additions and 7 deletions
|
@ -981,14 +981,11 @@ load_source_module(char *name, char *pathname, FILE *fp)
|
|||
}
|
||||
#if SIZEOF_TIME_T > 4
|
||||
/* Python's .pyc timestamp handling presumes that the timestamp fits
|
||||
in 4 bytes. This will be fine until sometime in the year 2038,
|
||||
when a 4-byte signed time_t will overflow.
|
||||
in 4 bytes. Since the code only does an equality comparison,
|
||||
ordering is not important and we can safely ignore the higher bits
|
||||
(collisions are extremely unlikely).
|
||||
*/
|
||||
if (st.st_mtime >> 32) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"modification time overflows a 4 byte field");
|
||||
return NULL;
|
||||
}
|
||||
st.st_mtime &= 0xFFFFFFFF;
|
||||
#endif
|
||||
cpathname = make_compiled_pathname(pathname, buf,
|
||||
(size_t)MAXPATHLEN + 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue