projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2f853dd
)
fix if_nametoindex return value when socket open fails
author
Ron Yorston
<rmy@frippery.org>
Fri, 15 Jan 2016 09:39:44 +0000
(09:39 +0000)
committer
Rich Felker
<dalias@aerifal.cx>
Sun, 17 Jan 2016 22:33:49 +0000
(17:33 -0500)
The return value of if_nametoindex is unsigned; it should return 0
on error.
src/network/if_nametoindex.c
patch
|
blob
|
history
diff --git
a/src/network/if_nametoindex.c
b/src/network/if_nametoindex.c
index cb6ec054efbd971fc362bc7dd24c738fc12eb997..331413c68912daf5157988df60f3605c8d818750 100644
(file)
--- 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);