mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-24 14:51:11 +01:00
Only check in-boundsness of seconds when time_t is smaller than i64
Otherwise coverity complains that we're checking an whether an int64 is less than INT64_MIN, which of course it isn't. Fixes CID 1357176. Not in any released Tor.
This commit is contained in:
parent
049445bca3
commit
4bb44f2c15
1 changed files with 4 additions and 1 deletions
|
@ -1528,11 +1528,14 @@ tor_timegm(const struct tm *tm, time_t *time_out)
|
|||
seconds = minutes*60 + tm->tm_sec;
|
||||
/* Check that "seconds" will fit in a time_t. On platforms where time_t is
|
||||
* 32-bit, this check will fail for dates in and after 2038.
|
||||
* "seconds" can't be negative, because "year" >= 1970. */
|
||||
*
|
||||
* We already know that "seconds" can't be negative because "year" >= 1970 */
|
||||
#if SIZEOF_TIME_T < 8
|
||||
if (seconds < TIME_MIN || seconds > TIME_MAX) {
|
||||
log_warn(LD_BUG, "Result does not fit in tor_timegm");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
*time_out = (time_t)seconds;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue