summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>2002-03-13 10:34:47 +0000
committerbrian <brian@cvs.openbsd.org>2002-03-13 10:34:47 +0000
commitbd78063068b1bf12be6c5c27754de51462c8c37d (patch)
treec51630e0e6e6e0778f03dd9845adf258c0ae7cfc
parent28857c6da590c454e695be1822fa6e2cbc7b24a8 (diff)
Use the return value from snprintf() to keep a track of the length of
the display string in MPPEDispOpts.
-rw-r--r--usr.sbin/ppp/ppp/mppe.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/usr.sbin/ppp/ppp/mppe.c b/usr.sbin/ppp/ppp/mppe.c
index 1d3b0bfcb6c..41c0de34751 100644
--- a/usr.sbin/ppp/ppp/mppe.c
+++ b/usr.sbin/ppp/ppp/mppe.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: mppe.c,v 1.10 2001/09/04 22:12:32 brian Exp $
+ * $OpenBSD: mppe.c,v 1.11 2002/03/13 10:34:46 brian Exp $
*/
#include <sys/types.h>
@@ -367,40 +367,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, ")");