diff --git a/usr.sbin/rtsold/dump.c b/usr.sbin/rtsold/dump.c index 6c10e389cb65..45646d00cdbe 100644 --- a/usr.sbin/rtsold/dump.c +++ b/usr.sbin/rtsold/dump.c @@ -1,5 +1,5 @@ -/* $NetBSD: dump.c,v 1.4 2000/10/06 00:13:02 itojun Exp $ */ -/* $KAME: dump.c,v 1.8 2000/10/05 22:20:39 itojun Exp $ */ +/* $NetBSD: dump.c,v 1.5 2001/08/22 05:24:37 itojun Exp $ */ +/* $KAME: dump.c,v 1.9 2001/08/20 06:55:54 itojun Exp $ */ /* * Copyright (C) 1999 WIDE Project. @@ -117,6 +117,8 @@ sec2str(total) int days, hours, mins, secs; int first = 1; char *p = result; + char *ep = &result[sizeof(result)]; + int n; days = total / 3600 / 24; hours = (total / 3600) % 24; @@ -125,17 +127,26 @@ sec2str(total) if (days) { first = 0; - p += sprintf(p, "%dd", days); + n = snprintf(p, ep - p, "%dd", days); + if (n < 0 || n >= ep - p) + return "?"; + p += n; } if (!first || hours) { first = 0; - p += sprintf(p, "%dh", hours); + n = snprintf(p, ep - p, "%dh", hours); + if (n < 0 || n >= ep - p) + return "?"; + p += n; } if (!first || mins) { first = 0; - p += sprintf(p, "%dm", mins); + n = snprintf(p, ep - p, "%dm", mins); + if (n < 0 || n >= ep - p) + return "?"; + p += n; } - sprintf(p, "%ds", secs); + snprintf(p, ep - p, "%ds", secs); return(result); } diff --git a/usr.sbin/rtsold/rtsold.8 b/usr.sbin/rtsold/rtsold.8 index 7d465c10495d..342fd2759038 100644 --- a/usr.sbin/rtsold/rtsold.8 +++ b/usr.sbin/rtsold/rtsold.8 @@ -1,5 +1,5 @@ -.\" $NetBSD: rtsold.8,v 1.12 2000/10/15 12:25:17 bjh21 Exp $ -.\" $KAME: rtsold.8,v 1.14 2000/08/13 18:06:39 itojun Exp $ +.\" $NetBSD: rtsold.8,v 1.13 2001/08/22 05:24:37 itojun Exp $ +.\" $KAME: rtsold.8,v 1.17 2001/07/09 22:30:37 itojun Exp $ .\" .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. .\" All rights reserved. @@ -37,10 +37,10 @@ .Nd router solicitation daemon .\" .Sh SYNOPSIS -.Nm +.Nm rtsold .Op Fl dDfm1 .Ar interface ... -.Nm "" +.Nm rtsold .Op Fl dDfm1 .Fl a .Nm rtsol @@ -131,7 +131,8 @@ Upon receipt of signal will dump the current internal state into .Pa /var/run/rtsold.dump . .\" -.Sh OPTIONS +.Pp +The options are as follows: .Bl -tag -width indent .It Fl a Autoprobe outgoing interface. diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c index 3f1d23d868de..f4fde92c1ffb 100644 --- a/usr.sbin/rtsold/rtsold.c +++ b/usr.sbin/rtsold/rtsold.c @@ -1,5 +1,5 @@ -/* $NetBSD: rtsold.c,v 1.10 2001/07/09 06:04:29 itojun Exp $ */ -/* $KAME: rtsold.c,v 1.31 2001/05/22 06:03:06 jinmei Exp $ */ +/* $NetBSD: rtsold.c,v 1.11 2001/08/22 05:24:37 itojun Exp $ */ +/* $KAME: rtsold.c,v 1.32 2001/07/09 22:34:07 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -109,7 +109,8 @@ main(argc, argv) int argc; char *argv[]; { - int s, rtsock, maxfd, ch; + int s, maxfd, ch; + int rtsock; int once = 0; struct timeval *timeout; struct fd_set fdset;