Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Year 2038 problem in plistlib #70896

Closed
serhiy-storchaka opened this issue Apr 7, 2016 · 4 comments
Closed

Year 2038 problem in plistlib #70896

serhiy-storchaka opened this issue Apr 7, 2016 · 4 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 26709
Nosy @ronaldoussoren, @abalkin, @serhiy-storchaka
Files
  • plistlib_large_timestamp.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2016-04-08.12:06:41.600>
    created_at = <Date 2016-04-07.09:46:22.351>
    labels = ['type-bug', 'library']
    title = 'Year 2038 problem in plistlib'
    updated_at = <Date 2016-04-08.12:06:41.599>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2016-04-08.12:06:41.599>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2016-04-08.12:06:41.600>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2016-04-07.09:46:22.351>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['42391']
    hgrepos = []
    issue_num = 26709
    keywords = ['patch']
    message_count = 4.0
    messages = ['262986', '263017', '263022', '263023']
    nosy_count = 4.0
    nosy_names = ['ronaldoussoren', 'belopolsky', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue26709'
    versions = ['Python 3.5', 'Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Apr 7, 2016
    @ronaldoussoren
    Copy link
    Contributor

    Patch looks good to me.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 8, 2016

    New changeset ba35b0404163 by Serhiy Storchaka in branch '3.5':
    Issue bpo-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 bpo-26709: Fixed Y2038 problem in loading binary PLists.
    https://hg.python.org/cpython/rev/778ccbe3cf74

    @serhiy-storchaka
    Copy link
    Member Author

    Thanks Ronald.

    @serhiy-storchaka serhiy-storchaka self-assigned this Apr 8, 2016
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants