[issue26709] Year 2038 problem in plistlib

Serhiy Storchaka report at bugs.python.org
Thu Apr 7 05:46:22 EDT 2016


New submission from Serhiy Storchaka:

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.

----------
components: Library (Lib)
files: plistlib_large_timestamp.patch
keywords: patch
messages: 262986
nosy: belopolsky, ronaldoussoren, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Year 2038 problem in plistlib
type: behavior
versions: Python 3.5, Python 3.6
Added file: http://bugs.python.org/file42391/plistlib_large_timestamp.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26709>
_______________________________________


More information about the Python-bugs-list mailing list