aboutsummaryrefslogtreecommitdiff
path: root/libntp/statestr.c
diff options
context:
space:
mode:
Diffstat (limited to 'libntp/statestr.c')
-rw-r--r--libntp/statestr.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/libntp/statestr.c b/libntp/statestr.c
index 313cd46bebfe..b8fa53ccb07f 100644
--- a/libntp/statestr.c
+++ b/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;
}
}