1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
From 3cdbfb99c3beda1e04efcc94f0af2abc8dc5d4ad Mon Sep 17 00:00:00 2001
From: Ron Yorston <rmy@frippery.org>
Date: Fri, 15 Jan 2016 09:39:44 +0000
Subject: [PATCH] fix if_nametoindex return value when socket open fails
The return value of if_nametoindex is unsigned; it should return 0
on error.
---
src/network/if_nametoindex.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/network/if_nametoindex.c b/src/network/if_nametoindex.c
index cb6ec05..331413c 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);
--
2.7.4
|