Explorar o código

fix if_nametoindex return value when socket open fails

The return value of if_nametoindex is unsigned; it should return 0
on error.
Ron Yorston %!s(int64=9) %!d(string=hai) anos
pai
achega
3cdbfb99c3
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      src/network/if_nametoindex.c

+ 1 - 1
src/network/if_nametoindex.c

@@ -10,7 +10,7 @@ unsigned if_nametoindex(const char *name)
 	struct ifreq ifr;
 	int fd, r;
 
-	if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) return -1;
+	if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) return 0;
 	strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
 	r = ioctl(fd, SIOCGIFINDEX, &ifr);
 	__syscall(SYS_close, fd);