summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Thomas McBride <mcbride@cvs.openbsd.org>2004-03-08 17:21:53 +0000
committerRyan Thomas McBride <mcbride@cvs.openbsd.org>2004-03-08 17:21:53 +0000
commit9cf9d870ef44e4fc1742523409328f5a4d19c950 (patch)
tree7b9a4a0e1d3faa8376c339e491bdccf2eb2f69f4
parent95f24fe1a71ad7ba51f024947047ecb59658f704 (diff)
Prevent user from specifying an interface name longer than IFNAMSIZ.
ok millert@
-rw-r--r--sbin/ifconfig/ifconfig.c11
1 files changed, 6 insertions, 5 deletions
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++)