summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2001-08-18 22:43:11 +0000
committerbrian <brian@FreeBSD.org>2001-08-18 22:43:11 +0000
commitd100840eb7b3d72a075f3d3054a695e8ea3b03eb (patch)
tree2bac82065af28df764244c67c53be0dc576bc440 /usr.sbin
parent1f224ee69c85230adf44e21d13c1a5d0b034cfc2 (diff)
downloadFreeBSD-src-d100840eb7b3d72a075f3d3054a695e8ea3b03eb.zip
FreeBSD-src-d100840eb7b3d72a075f3d3054a695e8ea3b03eb.tar.gz
Better handling for the return of snprintf().
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/command.c13
-rw-r--r--usr.sbin/ppp/mp.c4
2 files changed, 12 insertions, 5 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index 2c79b89..36cd8ed 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -255,14 +255,17 @@ HelpCommand(struct cmdargs const *arg)
static int
IdentCommand(struct cmdargs const *arg)
{
- int f, pos;
+ int f, max, n, pos;
*arg->cx->physical->link.lcp.cfg.ident = '\0';
+ max = sizeof arg->cx->physical->link.lcp.cfg.ident;
- for (pos = 0, f = arg->argn; f < arg->argc; f++)
- pos += snprintf(arg->cx->physical->link.lcp.cfg.ident + pos,
- sizeof arg->cx->physical->link.lcp.cfg.ident - pos, "%s%s",
- f == arg->argn ? "" : " ", arg->argv[f]);
+ 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)
+ break;
+ }
return 0;
}
diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c
index ac9321b..f288c8d 100644
--- a/usr.sbin/ppp/mp.c
+++ b/usr.sbin/ppp/mp.c
@@ -1124,6 +1124,10 @@ mpserver_Open(struct mpserver *s, struct peerid *peer)
l = snprintf(s->socket.sun_path, sizeof s->socket.sun_path, "%sppp-%s-%02x-",
_PATH_VARRUN, peer->authname, peer->enddisc.class);
+ if (l < 0) {
+ log_Printf(LogERROR, "mpserver: snprintf(): %s\n", strerror(errno));
+ return MPSERVER_FAILED;
+ }
for (f = 0; f < peer->enddisc.len && l < sizeof s->socket.sun_path - 2; f++) {
snprintf(s->socket.sun_path + l, sizeof s->socket.sun_path - l,
OpenPOWER on IntegriCloud