[SERVER-64397] TimeSorter comparator int overflow Created: 09/Mar/22  Updated: 29/Oct/23  Resolved: 15/Mar/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.0.0-rc0, 5.0.16

Type: Bug Priority: Major - P3
Reporter: David Percy Assignee: David Percy
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.0
Sprint: QO 2022-03-21
Participants:
Linked BF Score: 178

 Description   

In document_source_sorter.h:

    struct Comp {
        int operator()(Date_t x, Date_t y) const {
            return x.toMillisSinceEpoch() - y.toMillisSinceEpoch();
        }
    };

It's pretty easy to overflow this int because 2^32 milliseconds is only a couple months.



 Comments   
Comment by Githook User [ 21/Feb/23 ]

Author:

{'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}

Message: SERVER-64397 Fix int overflow in TimeSorter
Branch: v5.0
https://github.com/mongodb/mongo/commit/cc20266bb060babac3752b509665ea52b5307013

Comment by Githook User [ 14/Mar/22 ]

Author:

{'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}

Message: SERVER-64397 Fix int overflow in TimeSorter
Branch: master
https://github.com/mongodb/mongo/commit/353307a5cee706318068b07527c32bcbfdb92558

Generated at Thu Feb 08 06:00:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.