Skip to content

Commit d87448d

Browse files
authored
Merge pull request #527 from naemon/remove_tv_str_light
Fix memory corruption in mkstr caused by integer overflow
2 parents eecfb11 + 6a22f40 commit d87448d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Breaking changes:
55
Features:
66
* new attribute 'check_timeout' on `host` and `service` structs, overrides the global host / service check timeouts. (#525)
77

8+
Bugfixes:
9+
* fix memory corruption in `mkstr` caused by integer overflow (#527)
10+
811
1.5.0 - Feb 03 2026
912
===================
1013
Breaking changes:

lib/nsutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ float tv_delta_f(const struct timeval *start, const struct timeval *stop)
7070

7171
/* format duration seconds into human readable string */
7272
const char* tv_str(struct timeval *tv) {
73-
return (char *)mkstr("%lu.%06lu", tv->tv_sec, tv->tv_usec);
73+
return (char *)mkstr("%lld.%06ld", (long long)tv->tv_sec, (long)tv->tv_usec);
7474
}
7575

7676
/* Convert string to timeval */
@@ -94,7 +94,7 @@ int str2timeval(char *str, struct timeval *tv)
9494
const char *mkstr(const char *fmt, ...)
9595
{
9696
static char buf[MKSTR_BUFS][32]; /* 8k statically on the stack */
97-
static int slot = 0;
97+
static unsigned int slot = 0;
9898
char *ret;
9999

100100
va_list ap;

0 commit comments

Comments
 (0)