diff options
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/common/util.c b/src/common/util.c index f4d293c838..0ea70952a8 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1670,7 +1670,11 @@ format_time_interval(char *out, size_t out_len, long interval) { /* We only report seconds if there's no hours. */ long sec = 0, min = 0, hour = 0, day = 0; - if (interval < 0) + + /* -LONG_MIN is LONG_MAX + 1, which causes signed overflow */ + if (interval < -LONG_MAX) + interval = LONG_MAX; + else if (interval < 0) interval = -interval; if (interval >= 86400) { |