[SERVER-10102] mongo::Date_t::toTimeT conversion bug. Created: 05/Jul/13 Updated: 10/Dec/14 Resolved: 16/Sep/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Client |
| Affects Version/s: | 2.4.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Trivial - P5 |
| Reporter: | Sergey Volkov | Assignee: | Andy Schwerin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Participants: |
| Description |
|
unsigned long long is not best suitable to store date/time values because its may be negative. Or cast it correctly anywhere. return millis / 1000; this makes unsigned division and return incorrect time_t for negative ( less than '1970-01-01' ) must be: Thanks. |
| Comments |
| Comment by Andy Schwerin [ 05/Jul/13 ] |
|
Date_t cannot currently represent times before 1970-01-01. Note that at lines 97 and 98 in mongo/bson/misc.h, the code checks that millis is legally convertible to a time_t, and throws an exception if it is not. |