diff options
author | Ron Yorston <rmy@frippery.org> | 2016-01-15 09:39:44 +0000 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2016-01-17 17:33:49 -0500 |
commit | 3cdbfb99c3beda1e04efcc94f0af2abc8dc5d4ad (patch) | |
tree | f144fe52580b92edbd5bba528925d52caad3a250 | |
parent | 2f853dd6b9a95d5b13ee8f9df762125e0588df5d (diff) | |
download | musl-3cdbfb99c3beda1e04efcc94f0af2abc8dc5d4ad.tar.gz musl-3cdbfb99c3beda1e04efcc94f0af2abc8dc5d4ad.tar.xz musl-3cdbfb99c3beda1e04efcc94f0af2abc8dc5d4ad.zip |
fix if_nametoindex return value when socket open fails
The return value of if_nametoindex is unsigned; it should return 0 on error.
-rw-r--r-- | src/network/if_nametoindex.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/network/if_nametoindex.c b/src/network/if_nametoindex.c index cb6ec054..331413c6 100644 --- a/src/network/if_nametoindex.c +++ b/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); |