From: Enrico Scholz Date: Fri, 21 Nov 2003 16:01:09 +0000 (+0000) Subject: fixed uninitialized variables when ioctl() on the given interfaces X-Git-Tag: version_0_26~3 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=612cf424580257ce75cb1309558ee9bc6526cd36;p=util-vserver.git fixed uninitialized variables when ioctl() on the given interfaces fails (thanks to Herbert Poetzl) git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/branches/SYSCALL_SWITCH@439 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/src/ifspec.c b/util-vserver/src/ifspec.c index cebe4d0..7d665d2 100644 --- a/util-vserver/src/ifspec.c +++ b/util-vserver/src/ifspec.c @@ -104,7 +104,7 @@ int ifconfig_print ( struct { unsigned long addr; unsigned long mask; - } solved; + } solved = {0,0}; if (addrstr != NULL && addrstr[0] != '\0'){ printf ("ADDR=%s\n",addrstr); solved.addr = ip_cnv (addrstr); @@ -119,6 +119,10 @@ int ifconfig_print ( solved.addr = addr; ret = 0; } + else { + perror("ioctl(SIOCGIFADDR)"); + } + if (maskstr != NULL && maskstr[0] != '\0'){ printf ("NETMASK=%s\n",maskstr); solved.mask = ip_cnv (maskstr); @@ -133,6 +137,10 @@ int ifconfig_print ( solved.mask = addr; ret = 0; } + else { + perror("ioctl(SIOCGIFNETMASK)"); + } + if (bcaststr != NULL && bcaststr[0] != '\0'){ printf ("BCAST=%s\n",bcaststr); }else if (ifconfig_ioctl(skfd,ifname,SIOCGIFBRDADDR, &ifr) >= 0){ @@ -144,7 +152,7 @@ int ifconfig_print ( ,(addr>>8)&0xff ,addr&0xff); ret = 0; - }else{ + }else if (solved.addr!=0 && solved.mask!=0) { // Can't get it from the kernel, compute it from the IP // and the netmask unsigned long addr = (solved.addr & solved.mask)