X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Ftime-util.c;h=947ac1fcfb23075f1abd69119568fe32ebaaad3a;hb=d5d8429a12c4b1ef0dcd226c0904f00f4fa4898a;hp=33d0822f335ace06ff2583a4869f535c7254297a;hpb=75a5f1d837739fc84a7c5af14797490774a10646;p=elogind.git diff --git a/src/shared/time-util.c b/src/shared/time-util.c index 33d0822f3..947ac1fcf 100644 --- a/src/shared/time-util.c +++ b/src/shared/time-util.c @@ -296,8 +296,14 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) { assert(buf); assert(l > 0); - if (t == USEC_INFINITY || t <= 0) { - strncpy(p, t == USEC_INFINITY ? "infinity" : "0", l); + if (t == USEC_INFINITY) { + strncpy(p, "infinity", l-1); + p[l-1] = 0; + return p; + } + + if (t <= 0) { + strncpy(p, "0", l-1); p[l-1] = 0; return p; } @@ -959,7 +965,7 @@ bool timezone_is_valid(const char *name) { if (slash) return false; - t = strappenda("/usr/share/zoneinfo/", name); + t = strjoina("/usr/share/zoneinfo/", name); if (stat(t, &st) < 0) return false;