summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Schatz <genius3000@g3k.solutions>2019-07-04 10:42:41 -0600
committerPeter Powell <petpow@saberuk.com>2019-07-04 17:42:41 +0100
commit4681faacb542f75cf3ceba6924e3e936a809e01e (patch)
treeb4e98f62fab2ff744b8f745b0c1af546bbb50903
parent3b8246ab07faa673bf4e11b8aa927a9d724aa7d3 (diff)
DurationString(): Return "0s" for a duration of 0 (#1677).
Usually a duration of 0 is not allowed or handled separately, but it can also be used as a 'no set time' without separation. Case in point: m_chanhistory calls DurationString() to convert the max time seconds back to a human readable string for the mode serializer. Returning a blank string is bad here.
-rw-r--r--src/helperfuncs.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 386d6dafc..70ac2f0e6 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -432,6 +432,9 @@ bool InspIRCd::IsValidDuration(const std::string& duration)
std::string InspIRCd::DurationString(time_t duration)
{
+ if (duration == 0)
+ return "0s";
+
time_t years = duration / 31449600;
time_t weeks = (duration / 604800) % 52;
time_t days = (duration / 86400) % 7;