diff options
Diffstat (limited to 'contrib/ntp/libntp/statestr.c')
-rw-r--r-- | contrib/ntp/libntp/statestr.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/contrib/ntp/libntp/statestr.c b/contrib/ntp/libntp/statestr.c index 313cd46bebfe..b8fa53ccb07f 100644 --- a/contrib/ntp/libntp/statestr.c +++ b/contrib/ntp/libntp/statestr.c @@ -355,13 +355,12 @@ decode_bitflags( for (b = 0; b < tab_ct; b++) { if (tab[b].code & bits) { - rc = snprintf(pch, (lim - pch), "%s%s", sep, + size_t avail = lim - pch; + rc = snprintf(pch, avail, "%s%s", sep, tab[b].string); - if (rc < 0) - goto toosmall; - pch += (u_int)rc; - if (pch >= lim) + if ((size_t)rc >= avail) goto toosmall; + pch += rc; sep = sep2; } } |