From 9cf9d870ef44e4fc1742523409328f5a4d19c950 Mon Sep 17 00:00:00 2001 From: Ryan Thomas McBride Date: Mon, 8 Mar 2004 17:21:53 +0000 Subject: Prevent user from specifying an interface name longer than IFNAMSIZ. ok millert@ --- sbin/ifconfig/ifconfig.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'sbin/ifconfig/ifconfig.c') diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 41c44702c52..4a36b997fa9 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.90 2004/02/26 20:25:09 millert Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.91 2004/03/08 17:21:52 mcbride Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -77,7 +77,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; #else -static const char rcsid[] = "$OpenBSD: ifconfig.c,v 1.90 2004/02/26 20:25:09 millert Exp $"; +static const char rcsid[] = "$OpenBSD: ifconfig.c,v 1.91 2004/03/08 17:21:52 mcbride Exp $"; #endif #endif /* not lint */ @@ -437,11 +437,12 @@ main(int argc, char *argv[]) argc--, argv++; if (argc < 1) usage(); - (void) strlcpy(name, *argv, sizeof(name)); + if (strlcpy(name, *argv, sizeof(name)) >= IFNAMSIZ) + errx(1, "interface name '%s' too long", *argv); } else if (!strcmp(*argv, "-C")) { Cflag = 1; - } else - (void) strlcpy(name, *argv, sizeof(name)); + } else if (strlcpy(name, *argv, sizeof(name)) >= IFNAMSIZ) + errx(1, "interface name '%s' too long", *argv); argc--, argv++; if (argc > 0) { for (afp = rafp = afs; rafp->af_name; rafp++) -- cgit v1.2.3