diff --git a/src/shared/wpas.c b/src/shared/wpas.c index 4b2adea..171a472 100644 --- a/src/shared/wpas.c +++ b/src/shared/wpas.c @@ -742,6 +742,7 @@ static int wpas__parse_message(struct wpas *w, const char *ifname = NULL; unsigned int level; char *pos; + char *orig_raw = raw; int r, num; bool is_event = false; @@ -751,7 +752,7 @@ static int wpas__parse_message(struct wpas *w, ifname = pos; pos = strchrnul(pos, ' '); if (*pos) - *pos++ = 0; + pos++; len -= pos - raw; raw = pos; @@ -811,15 +812,12 @@ static int wpas__parse_message(struct wpas *w, m->sealed = true; m->rawlen = len; - m->raw = malloc(len + 1); + m->raw = strdup(orig_raw); if (!m->raw) return -ENOMEM; - /* copy with 0-terminator */ - memcpy(m->raw, raw, len + 1); - if (ifname) { - m->ifname = strdup(ifname); + m->ifname = strndup(ifname, strchrnul(ifname, ' ') - ifname); if (!m->ifname) return -ENOMEM; } diff --git a/src/wifi/wifid-link.c b/src/wifi/wifid-link.c index ff9eb62..b2de058 100644 --- a/src/wifi/wifid-link.c +++ b/src/wifi/wifid-link.c @@ -132,6 +132,16 @@ void link_free(struct link *l) free(l); } +void link_use_dev(struct link *l) +{ + l->use_dev = true; +} + +bool link_is_using_dev(struct link *l) +{ + return l->use_dev; +} + void link_set_managed(struct link *l, bool set) { int r; diff --git a/src/wifi/wifid-supplicant.c b/src/wifi/wifid-supplicant.c index 6a49fa4..d3e4dbe 100644 --- a/src/wifi/wifid-supplicant.c +++ b/src/wifi/wifid-supplicant.c @@ -2147,6 +2147,9 @@ static int supplicant_global_fn(struct wpas *w, } /* ignore events on the global-iface, we only listen on dev-iface */ + if(link_is_using_dev(s->l) && wpas_message_get_ifname(m)) { + supplicant_event(s, m); + } return 0; diff --git a/src/wifi/wifid.c b/src/wifi/wifid.c index 9533206..d2e8108 100644 --- a/src/wifi/wifid.c +++ b/src/wifi/wifid.c @@ -42,6 +42,7 @@ const char *interface_name = NULL; unsigned int arg_wpa_loglevel = LOG_NOTICE; +bool use_dev = false; /* * Manager Handling @@ -102,6 +103,9 @@ static void manager_add_udev_link(struct manager *m, link_set_friendly_name(l, m->friendly_name); + if(use_dev) + link_use_dev(l); + #ifdef RELY_UDEV if (udev_device_has_tag(d, "miracle")) { #else @@ -457,6 +461,7 @@ static int help(void) " -i --interface Choose the interface to use\n" "\n" " --wpa-loglevel