Fix two bugs: 1.) wrong sizeof for name 2.) if ns not configured
authorKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Sun, 11 Aug 1985 05:11:52 +0000 (21:11 -0800)
committerKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Sun, 11 Aug 1985 05:11:52 +0000 (21:11 -0800)
Don't barf when asked to report status.

SCCS-vsn: sbin/ifconfig/ifconfig.c 4.13

usr/src/sbin/ifconfig/ifconfig.c

index fc705fa..f0727d0 100644 (file)
@@ -14,7 +14,6 @@ char copyright[] =
 static char sccsid[] = "@(#)ifconfig.c 4.13 (Berkeley) %G%";
 #endif not lint
 
 static char sccsid[] = "@(#)ifconfig.c 4.13 (Berkeley) %G%";
 #endif not lint
 
-
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
@@ -117,8 +116,7 @@ main(argc, argv)
                exit(1);
        }
        argc--, argv++;
                exit(1);
        }
        argc--, argv++;
-       strncpy(name, *argv, sizeof(name - 1));
-       name[sizeof name - 1] = 0;
+       strncpy(name, *argv, sizeof(name));
        strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
        argc--, argv++;
        if (argc > 0) {
        strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
        argc--, argv++;
        if (argc > 0) {
@@ -346,11 +344,13 @@ xns_status()
        close(s);
        s = socket(AF_NS, SOCK_DGRAM, 0);
        if (s < 0) {
        close(s);
        s = socket(AF_NS, SOCK_DGRAM, 0);
        if (s < 0) {
+               if (errno == EAFNOSUPPORT)
+                       return;
                perror("ifconfig: socket");
                exit(1);
        }
        if (ioctl(s, SIOCGIFADDR, (caddr_t)&ifr) < 0) {
                perror("ifconfig: socket");
                exit(1);
        }
        if (ioctl(s, SIOCGIFADDR, (caddr_t)&ifr) < 0) {
-               if (errno == EAFNOSUPPORT)
+               if (errno == EADDRNOTAVAIL || errno==EAFNOSUPPORT)
                        return;
                Perror("ioctl (SIOCGIFADDR)");
        }
                        return;
                Perror("ioctl (SIOCGIFADDR)");
        }