Merge pull request #13707 from LabNConsulting/chopps/coverity-strftime

mgmtd: assert an assertion for coverity
This commit is contained in:
Donatas Abraitis 2023-06-07 09:12:31 +03:00 committed by GitHub
commit 75a95e1ccd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,9 +74,11 @@ mgmt_time_to_string(struct timespec *tv, bool long_fmt, char *buffer, size_t sz)
if (long_fmt) {
n = strftime(buffer, sz, MGMT_LONG_TIME_FMT, &tm);
assert(n < sz);
snprintf(&buffer[n], sz - n, ",%09lu", tv->tv_nsec);
} else {
n = strftime(buffer, sz, MGMT_SHORT_TIME_FMT, &tm);
assert(n < sz);
snprintf(&buffer[n], sz - n, "%09lu", tv->tv_nsec);
}