summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>2001-08-18 22:14:40 +0000
committerbrian <brian@cvs.openbsd.org>2001-08-18 22:14:40 +0000
commit1d67028f2292ff8ef592c61b42904037c5fbea5b (patch)
tree186ccbd04b8fc1bf06d33ce8b5ccc18d50b352c8 /usr.sbin
parente7fdf13effc542c6b6d5730d91d7f57fe2456e4b (diff)
Deal with snprintf() return codes properly
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/pppctl/pppctl.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.sbin/ppp/pppctl/pppctl.c b/usr.sbin/ppp/pppctl/pppctl.c
index 8bb8fa81a5a..341517814da 100644
--- a/usr.sbin/ppp/pppctl/pppctl.c
+++ b/usr.sbin/ppp/pppctl/pppctl.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: pppctl.c,v 1.7 2001/03/22 17:16:27 brian Exp $
+ * $Id: pppctl.c,v 1.8 2001/08/18 22:14:39 brian Exp $
*/
#include <sys/types.h>
@@ -202,7 +202,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;
@@ -257,11 +257,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);