summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-03-25 16:46:02 -0400
committerNick Mathewson <nickm@torproject.org>2016-03-25 16:46:02 -0400
commit4bb44f2c15b3f9e9b63d229af938e8a321556215 (patch)
tree8041a65f9de6b57b8cf4f328954abbf26920b26e
parent049445bca33e8578757639fc8a236540fd0fd154 (diff)
downloadtor-4bb44f2c15b3f9e9b63d229af938e8a321556215.tar.gz
tor-4bb44f2c15b3f9e9b63d229af938e8a321556215.zip
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.
-rw-r--r--src/common/util.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 820e8672ec..2351faf503 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -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;
}