[SERVER-11254] Check return value of time library functions in time_support.cpp Created: 17/Oct/13 Updated: 12/Sep/23 Resolved: 12/Sep/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | 2.5.3 |
| Fix Version/s: | 7.2.0-rc0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Shaun Verch | Assignee: | Erin McNulty |
| Resolution: | Done | Votes: | 1 |
| Labels: | neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Service Arch
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Operating System: | ALL | ||||||||
| Sprint: | Service Arch 2023-09-18 | ||||||||
| Participants: | |||||||||
| Description |
|
In https://github.com/mongodb/mongo/blob/r2.5.2/src/mongo/util/time_support.cpp#L171 we do not check the return value of many time related library functions, meaning that they currently can fail silently. |
| Comments |
| Comment by Githook User [ 12/Sep/23 ] |
|
Author: {'name': 'Erin McNulty', 'email': 'erin.mcnulty@mongodb.com', 'username': 'erin2722'}Message: |
| Comment by Gregory Noma [ 31/Jul/23 ] |
|
Double checked since this was from so long ago, looks like this code is still the same |
| Comment by Mathias Stearn [ 17/Oct/13 ] |
|
Some (not all) versions of the windows CRT don't support dates before 1970 and report errors for negative time_t. I think the right thing is probably to throw an exception. Eventually we should switch to a non-crappy date library so we don't have to worry about that or dates after 2038, but that isn't in scope for 2.6. |
| Comment by Shaun Verch [ 17/Oct/13 ] |
|
I'm not sure. Maybe it could be reported back to the caller to be handled appropriately based on context. Here's an example of checking these errors: https://github.com/mongodb/mongo/blob/r2.5.2/src/mongo/db/pipeline/value.cpp#L435 redbeard0531 would have a better description of what can go wrong inside these functions. |
| Comment by Eric Milkie [ 17/Oct/13 ] |
|
Not sure what you would do if the time function failed (or how it could fail). Would you abort the server? |