/* Wrapper for scan list */
static int iwinfo_L_scanlist(lua_State *L, int (*func)(const char *, char *, int *))
{
- int i, x, len;
+ int i, x, len = 0;
char rv[IWINFO_BUFSIZE];
char macstr[18];
const char *ifname = luaL_checkstring(L, 1);
int ifidx = -1, phyidx = -1;
struct nl80211_msg_conveyor *cv;
+ if (ifname == NULL)
+ return NULL;
+
if (nl80211_init() < 0)
return NULL;
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);
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));