summaryrefslogtreecommitdiff
path: root/package/network/utils/iwinfo/src/iwinfo_nl80211.c
diff options
context:
space:
mode:
Diffstat (limited to 'package/network/utils/iwinfo/src/iwinfo_nl80211.c')
-rw-r--r--package/network/utils/iwinfo/src/iwinfo_nl80211.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/package/network/utils/iwinfo/src/iwinfo_nl80211.c b/package/network/utils/iwinfo/src/iwinfo_nl80211.c
index 98200bf..33c6238 100644
--- a/package/network/utils/iwinfo/src/iwinfo_nl80211.c
+++ b/package/network/utils/iwinfo/src/iwinfo_nl80211.c
@@ -215,6 +215,9 @@ static struct nl80211_msg_conveyor * nl80211_msg(const char *ifname,
int ifidx = -1, phyidx = -1;
struct nl80211_msg_conveyor *cv;
+ if (ifname == NULL)
+ return NULL;
+
if (nl80211_init() < 0)
return NULL;
@@ -227,7 +230,8 @@ static struct nl80211_msg_conveyor * nl80211_msg(const char *ifname,
else
ifidx = if_nametoindex(ifname);
- if ((ifidx < 0) && (phyidx < 0))
+ /* Valid ifidx must be greater than 0 */
+ if ((ifidx <= 0) && (phyidx < 0))
return NULL;
cv = nl80211_new(nls->nl80211, cmd, flags);
@@ -500,12 +504,15 @@ static char * nl80211_phy2ifname(const char *ifname)
DIR *d;
struct dirent *e;
+ /* Only accept phy name of the form phy%d or radio%d */
if (!ifname)
return NULL;
else if (!strncmp(ifname, "phy", 3))
phyidx = atoi(&ifname[3]);
else if (!strncmp(ifname, "radio", 5))
phyidx = atoi(&ifname[5]);
+ else
+ return NULL;
memset(nif, 0, sizeof(nif));