diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Widen the cache ttl before multiplying it
A ttl in the tens of millions of minutes overflowed the int it was
multiplied in.
Diffstat (limited to 'source/cache.c')
| -rw-r--r-- | source/cache.c | 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 3 insertions, 1 deletion
diff --git a/source/cache.c b/source/cache.c index af391db..a076823 100644 --- a/source/cache.c +++ b/source/cache.c @@ -189,7 +189,9 @@ static int is_expired(struct cache_slot *slot) { if (slot->ttl < 0) return 0; - return slot->st.st_mtime + slot->ttl * SECONDS_PER_MINUTE < time(NULL); + // Widened before the multiply, since a ttl in the tens of millions of + // minutes overflows an int. + return slot->st.st_mtime + (time_t)slot->ttl * SECONDS_PER_MINUTE < time(NULL); } /* |
