summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorPierre-Yves Ritschard <pyr@cvs.openbsd.org>2007-07-30 12:34:31 +0000
committerPierre-Yves Ritschard <pyr@cvs.openbsd.org>2007-07-30 12:34:31 +0000
commit22d27f49ba026522dc3aa149e97026326d999abd (patch)
tree83c773deb7f176b14738003fe011fe17f8d320d9 /sbin
parent61c5794e357f1b86cd14f3590930261ceb0ec055 (diff)
avoid segfault when empty string is passed as interface name.
ok henning@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ifconfig/ifconfig.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index eca72a745db..baabf0cff22 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifconfig.c,v 1.182 2007/06/19 06:24:28 pyr Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.183 2007/07/30 12:34:30 pyr Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
@@ -777,7 +777,7 @@ printif(char *ifname, int ifaliases)
if ((oname = strdup(ifname)) == NULL)
err(1, "strdup");
nlen = strlen(oname);
- if (!isdigit(oname[nlen - 1])) /* is it a group? */
+ if (nlen && !isdigit(oname[nlen - 1])) /* is it a group? */
if (printgroup(oname, ifaliases) != -1)
return;
}
@@ -788,7 +788,7 @@ printif(char *ifname, int ifaliases)
namep = NULL;
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
if (oname) {
- if (isdigit(oname[nlen - 1])) {
+ if (nlen && isdigit(oname[nlen - 1])) {
/* must have exact match */
if (strcmp(oname, ifa->ifa_name) != 0)
continue;