[SERVER-59765] $dateAdd/$dateSubtract do not detect an overflow for certain 'amount' values Created: 03/Sep/21  Updated: 29/Oct/23  Resolved: 09/Sep/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.0.0, 5.1.0
Fix Version/s: 5.0.4, 5.1.0-rc0

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

Issue Links:
Backports
Depends
Documented
is documented by DOCS-14781 Investigate changes in SERVER-59765: ... Closed
Related
Backwards Compatibility: Minor Change
Operating System: ALL
Backport Requested:
v5.0
Sprint: QE 2021-09-06, QE 2021-09-20
Participants:
Linked BF Score: 136

 Description   

$dateAdd/$dateSubtract expressions do not detect an overflow for certain 'amount' values. A result is undefined in such cases. An example of an expression that overflows:

    {"$dateAdd":
            {"startDate" : Timestamp(0, 4294967295),
            "unit" : "month",
            "amount" :  {$multiply: [NumberLong("314159265358979383")]},
            "timezone" : "+1187" }};



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 21/Sep/21 ]

Author:

{'name': 'Mindaugas Malinauskas', 'email': 'mindaugas.malinauskas@mongodb.com'}

Message: SERVER-59765 Improved 'amount' parameter validation for $dateAdd/$dateSubtract

(cherry picked from commit f369292c627896fac3b7542974fd12bc509aef7c)
Branch: v5.0
https://github.com/mongodb/mongo/commit/c77a6cc4a64b894c59f7a06f6368c45f93a18396

Comment by Githook User [ 09/Sep/21 ]

Author:

{'name': 'Mindaugas Malinauskas', 'email': 'mindaugas.malinauskas@mongodb.com'}

Message: SERVER-59765 Improved 'amount' parameter validation for $dateAdd/$dateSubtract
Branch: master
https://github.com/mongodb/mongo/commit/f369292c627896fac3b7542974fd12bc509aef7c

Comment by Githook User [ 09/Sep/21 ]

Author:

{'name': 'Nikita Lapkov', 'email': 'nikita.lapkov@mongodb.com', 'username': 'laplab'}

Message: Revert "SERVER-59765 Improved 'amount' parameter validation for $dateAdd/$dateSubtract"

This reverts commit ec56b7edb4ffdee862df4b18c11690151253dde3.
Branch: master
https://github.com/mongodb/mongo/commit/6d2d8a296b9e1dcb14c0e794f6d3c7f492a883fe

Comment by Githook User [ 09/Sep/21 ]

Author:

{'name': 'Mindaugas Malinauskas', 'email': 'mindaugas.malinauskas@mongodb.com'}

Message: SERVER-59765 Improved 'amount' parameter validation for $dateAdd/$dateSubtract
Branch: master
https://github.com/mongodb/mongo/commit/ec56b7edb4ffdee862df4b18c11690151253dde3

Generated at Thu Feb 08 05:48:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.