From 2313781df23654556cd7d08ca63c3fc184ef1b63 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Mon, 20 Aug 2001 15:09:34 +0000 Subject: Handle snprintf() returning < 0 (not just -1) MFC after: 2 weeks --- usr.sbin/ppp/command.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'usr.sbin/ppp/command.c') diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 36cd8edf3b0a..ae68eec0701f 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -263,7 +263,11 @@ IdentCommand(struct cmdargs const *arg) for (pos = 0, f = arg->argn; f < arg->argc && pos < max; f++) { n = snprintf(arg->cx->physical->link.lcp.cfg.ident + pos, max - pos, "%s%s", f == arg->argn ? "" : " ", arg->argv[f]); - if (n == -1 || (pos += n) >= max) + if (n < 0) { + arg->cx->physical->link.lcp.cfg.ident[pos] = '\0'; + break; + } + if ((pos += n) >= max) break; } -- cgit v1.3