This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Year 2038 problem in plistlib
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: belopolsky, python-dev, ronaldoussoren, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2016-04-07 09:46 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
plistlib_large_timestamp.patch serhiy.storchaka, 2016-04-07 09:46 review
Messages (4)
msg262986 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-04-07 09:46
Plistlib fails to load dates before year 1901 and after year 2038 in binary format on platforms with 32-bit time_t.

>>> data = plistlib.dumps(datetime.datetime(1901, 1, 1), fmt=plistlib.FMT_BINARY)
>>> plistlib.loads(data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 1006, in loads
    fp, fmt=fmt, use_builtin_types=use_builtin_types, dict_type=dict_type)
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 997, in load
    return p.parse(fp)
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 623, in parse
    return self._read_object(self._object_offsets[top_object])
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 688, in _read_object
    return datetime.datetime.utcfromtimestamp(f + (31 * 365 + 8) * 86400)
OverflowError: timestamp out of range for platform time_t
>>> data = plistlib.dumps(datetime.datetime(2039, 1, 1), fmt=plistlib.FMT_BINARY)
>>> plistlib.loads(data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 1006, in loads
    fp, fmt=fmt, use_builtin_types=use_builtin_types, dict_type=dict_type)
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 997, in load
    return p.parse(fp)
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 623, in parse
    return self._read_object(self._object_offsets[top_object])
  File "/home/serhiy/py/cpython/Lib/plistlib.py", line 688, in _read_object                                                                                                                    
    return datetime.datetime.utcfromtimestamp(f + (31 * 365 + 8) * 86400)                                                                                                                      
OverflowError: timestamp out of range for platform time_t

Proposed patch fixes this issue.
msg263017 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2016-04-08 10:54
Patch looks good to me.
msg263022 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-04-08 12:01
New changeset ba35b0404163 by Serhiy Storchaka in branch '3.5':
Issue #26709: Fixed Y2038 problem in loading binary PLists.
https://hg.python.org/cpython/rev/ba35b0404163

New changeset 778ccbe3cf74 by Serhiy Storchaka in branch 'default':
Issue #26709: Fixed Y2038 problem in loading binary PLists.
https://hg.python.org/cpython/rev/778ccbe3cf74
msg263023 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-04-08 12:06
Thanks Ronald.
History
Date User Action Args
2022-04-11 14:58:29adminsetgithub: 70896
2016-04-08 12:06:41serhiy.storchakasetstatus: open -> closed
messages: + msg263023

assignee: serhiy.storchaka
resolution: fixed
stage: patch review -> resolved
2016-04-08 12:01:05python-devsetnosy: + python-dev
messages: + msg263022
2016-04-08 10:54:26ronaldoussorensetmessages: + msg263017
2016-04-07 09:46:22serhiy.storchakacreate