aboutsummaryrefslogtreecommitdiffstats
path: root/iw_scan.c
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2020-07-29 23:11:46 +0100
committerJonathan McCrohan <jmccrohan@gmail.com>2020-07-29 23:11:46 +0100
commit8deb3660926fe8278948b898b9c1b772eed2e61e (patch)
treecc46239969468c1f4017da7aac5420664b5bbd22 /iw_scan.c
parent1fc41b776f712f321c1f355d391c6a5eaf79ebfa (diff)
downloadwavemon-8deb3660926fe8278948b898b9c1b772eed2e61e.tar.gz
New upstream version 0.9.1upstream/0.9.1upstream
Diffstat (limited to '')
-rw-r--r--iw_scan.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/iw_scan.c b/iw_scan.c
index 2748376..b9b1f9c 100644
--- a/iw_scan.c
+++ b/iw_scan.c
@@ -143,7 +143,7 @@ static bool wait_for_scan_events(void)
int scan_dump_handler(struct nl_msg *msg, void *arg)
{
struct scan_result *sr = (struct scan_result *)arg;
- struct scan_entry *new = calloc(1, sizeof(*new));
+ struct scan_entry *new;
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
struct nlattr *tb[NL80211_ATTR_MAX + 1];
struct nlattr *bss[NL80211_BSS_MAX + 1];
@@ -209,9 +209,10 @@ int scan_dump_handler(struct nl_msg *msg, void *arg)
if (bss[NL80211_BSS_INFORMATION_ELEMENTS]) {
uint8_t *ie = nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]);
int ielen = nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]);
- uint8_t len = ie[1];
- while (ielen >= 2 && ielen >= ie[1]) {
+ while (ielen >= 2 && ielen >= ie[1]) {
+ uint8_t len = ie[1];
+
switch (ie[0]) {
case 0: /* SSID */
if (len > 0 && len <= 32)
@@ -227,7 +228,7 @@ int scan_dump_handler(struct nl_msg *msg, void *arg)
}
ielen -= ie[1] + 2;
ie += ie[1] + 2;
- }
+ }
}
/* Update stats */
@@ -429,6 +430,8 @@ void *do_scan(void *sr_ptr)
if (if_set_up(conf_ifname()) < 0)
err_sys("Can not bring up interface '%s'", conf_ifname());
+ if (atexit(if_set_down_on_exit) < 0)
+ snprintf(sr->msg, sizeof(sr->msg), "Warning: unable to restore %s down state on exit", conf_ifname());
break;
}
/* fall through */