summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pppctl
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2001-08-18 22:46:06 +0000
committerbrian <brian@FreeBSD.org>2001-08-18 22:46:06 +0000
commitd01d678e4da36081c27805c5ccb5b83ec528cfe9 (patch)
treef40876645a1e2fc9e27356fde10e7649ec1dc749 /usr.sbin/pppctl
parentd100840eb7b3d72a075f3d3054a695e8ea3b03eb (diff)
downloadFreeBSD-src-d01d678e4da36081c27805c5ccb5b83ec528cfe9.zip
FreeBSD-src-d01d678e4da36081c27805c5ccb5b83ec528cfe9.tar.gz
Better handling of the return from snprintf
Diffstat (limited to 'usr.sbin/pppctl')
-rw-r--r--usr.sbin/pppctl/pppctl.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.sbin/pppctl/pppctl.c b/usr.sbin/pppctl/pppctl.c
index 4ec2d94..be9b73c 100644
--- a/usr.sbin/pppctl/pppctl.c
+++ b/usr.sbin/pppctl/pppctl.c
@@ -345,7 +345,7 @@ main(int argc, char **argv)
struct sockaddr *sock;
struct sockaddr_in ifsin;
struct sockaddr_un ifsun;
- int socksz, arg, fd, len, verbose, save_errno, hide1, hide1off, hide2;
+ int n, socksz, arg, fd, len, verbose, save_errno, hide1, hide1off, hide2;
unsigned TimeoutVal;
char *DoneWord = "x", *next, *start;
struct sigaction act, oact;
@@ -404,11 +404,16 @@ main(int argc, char **argv)
for (harg = pos = 0; harg < argc; harg++)
if (harg == 0 || harg != hide2) {
if (harg == 0 || harg != hide1)
- pos += snprintf(title + pos, sizeof title - pos, "%s%s",
+ n = snprintf(title + pos, sizeof title - pos, "%s%s",
harg ? " " : "", argv[harg]);
else if (hide1off > 1)
- pos += snprintf(title + pos, sizeof title - pos, " %.*s",
+ n = snprintf(title + pos, sizeof title - pos, " %.*s",
hide1off, argv[harg]);
+ else
+ n = 0;
+ if (n < 0 || n >= sizeof title - pos)
+ break;
+ pos += n;
}
#ifdef __FreeBSD__
setproctitle("-%s", title);
OpenPOWER on IntegriCloud