summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2002-03-13 10:21:19 +0000
committerbrian <brian@FreeBSD.org>2002-03-13 10:21:19 +0000
commit783a07fdf2cf9f07d154294161e490199ec54fae (patch)
treef98907a4d455b0aa5e1369de01247830c1e03cd7 /usr.sbin
parente7306442d5408a4d618291c090c044c285655a35 (diff)
downloadFreeBSD-src-783a07fdf2cf9f07d154294161e490199ec54fae.zip
FreeBSD-src-783a07fdf2cf9f07d154294161e490199ec54fae.tar.gz
Use the return value from snprintf() to keep a track of the length of
the display string in MPPEDispOpts. PR: 35836 MFC After: 2 weeks
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/mppe.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/usr.sbin/ppp/mppe.c b/usr.sbin/ppp/mppe.c
index 6278ad1..4b75cbf 100644
--- a/usr.sbin/ppp/mppe.c
+++ b/usr.sbin/ppp/mppe.c
@@ -369,40 +369,41 @@ MPPEDispOpts(struct lcp_opt *o)
static char buf[70];
u_int32_t val;
char ch;
- int len;
+ int len, n;
ua_ntohl(o->data, &val);
- snprintf(buf, sizeof buf, "value 0x%08x ", (unsigned)val);
- len = strlen(buf);
+ len = 0;
+ if ((n = snprintf(buf, sizeof buf, "value 0x%08x ", (unsigned)val)) > 0)
+ len += n;
if (!(val & MPPE_OPT_BITMASK)) {
- snprintf(buf + len, sizeof buf - len, "(0");
- len++;
+ if ((n = snprintf(buf + len, sizeof buf - len, "(0")) > 0)
+ len += n;
} else {
ch = '(';
if (val & MPPE_OPT_128BIT) {
- snprintf(buf + len, sizeof buf - len, "%c128", ch);
- len += strlen(buf + len);
+ if ((n = snprintf(buf + len, sizeof buf - len, "%c128", ch)) > 0)
+ len += n;
ch = '/';
}
if (val & MPPE_OPT_56BIT) {
- snprintf(buf + len, sizeof buf - len, "%c56", ch);
- len += strlen(buf + len);
+ if ((n = snprintf(buf + len, sizeof buf - len, "%c56", ch)) > 0)
+ len += n;
ch = '/';
}
if (val & MPPE_OPT_40BIT) {
- snprintf(buf + len, sizeof buf - len, "%c40", ch);
- len += strlen(buf + len);
+ if ((n = snprintf(buf + len, sizeof buf - len, "%c40", ch)) > 0)
+ len += n;
ch = '/';
}
}
- snprintf(buf + len, sizeof buf - len, " bits, state%s",
- (val & MPPE_OPT_STATELESS) ? "less" : "ful");
- len += strlen(buf + len);
+ if ((n = snprintf(buf + len, sizeof buf - len, " bits, state%s",
+ (val & MPPE_OPT_STATELESS) ? "less" : "ful")) > 0)
+ len += n;
if (val & MPPE_OPT_COMPRESSED) {
- snprintf(buf + len, sizeof buf - len, ", compressed");
- len += strlen(buf + len);
+ if ((n = snprintf(buf + len, sizeof buf - len, ", compressed")) > 0)
+ len += n;
}
snprintf(buf + len, sizeof buf - len, ")");
OpenPOWER on IntegriCloud