[PATCH v2] eap: fix uninitialized variable error
by James Prestwood
src/eap.c: In function 'eap_rx_packet':
src/eap.c:417:57: error: 'vendor_type' may be used uninitialized in this
function [-Werror=maybe-uninitialized]
417 | (type == EAP_TYPE_EXPANDED && vendor_id == (id) && vendor_type == (t))
---
src/eap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/eap.c b/src/eap.c
index 10381af7..b67049fd 100644
--- a/src/eap.c
+++ b/src/eap.c
@@ -424,7 +424,7 @@ static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
{
enum eap_type type;
uint32_t vendor_id;
- uint32_t vendor_type;
+ uint32_t vendor_type = 0;
enum eap_type our_type = eap->method->request_type;
uint32_t our_vendor_id = (eap->method->vendor_id[0] << 16) |
(eap->method->vendor_id[1] << 8) |
--
2.31.1
6 months, 1 week
[PATCH] eap: fix uninitialized variable error
by James Prestwood
src/eap.c: In function ‘eap_rx_packet’:
src/eap.c:417:57: error: ‘vendor_type’ may be used uninitialized in this
function [-Werror=maybe-uninitialized]
417 | (type == EAP_TYPE_EXPANDED && vendor_id == (id) && vendor_type == (t))
---
src/eap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/eap.c b/src/eap.c
index 10381af7..b67049fd 100644
--- a/src/eap.c
+++ b/src/eap.c
@@ -424,7 +424,7 @@ static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
{
enum eap_type type;
uint32_t vendor_id;
- uint32_t vendor_type;
+ uint32_t vendor_type = 0;
enum eap_type our_type = eap->method->request_type;
uint32_t our_vendor_id = (eap->method->vendor_id[0] << 16) |
(eap->method->vendor_id[1] << 8) |
--
2.31.1
6 months, 1 week
[PATCH 1/2] scan: use signal strength if bss ranks are equal
by James Prestwood
If two BSS's end up with the same rank sort them based on signal
strength so IWD still prefers the higher strength BSS.
---
src/scan.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/scan.c b/src/scan.c
index da7d129f..38a15c11 100644
--- a/src/scan.c
+++ b/src/scan.c
@@ -1628,6 +1628,10 @@ int scan_bss_rank_compare(const void *a, const void *b, void *user_data)
{
const struct scan_bss *new_bss = a, *bss = b;
+ if (bss->rank == new_bss->rank)
+ return (bss->signal_strength >
+ new_bss->signal_strength) ? 1 : -1;
+
return (bss->rank > new_bss->rank) ? 1 : -1;
}
--
2.31.1
6 months, 1 week
[PATCH] anqp: return the request ID rather than true
by James Prestwood
---
src/anqp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/anqp.c b/src/anqp.c
index a3c46635..8febdf91 100644
--- a/src/anqp.c
+++ b/src/anqp.c
@@ -256,7 +256,7 @@ uint32_t anqp_request(uint64_t wdev_id, const uint8_t *addr,
&anqp_frame_prefix, anqp_response_frame_event,
NULL);
- return true;
+ return request->id;
}
void anqp_cancel(uint32_t id)
--
2.31.1
6 months, 1 week
[PATCH] eap: Remove nested function use
by Marc-Antoine Perennou
This allows building iwd with clang
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine(a)Perennou.com>
---
src/eap.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/src/eap.c b/src/eap.c
index 0645be47..10381af7 100644
--- a/src/eap.c
+++ b/src/eap.c
@@ -416,6 +416,9 @@ static const char *eap_type_to_str(enum eap_type type, uint32_t vendor_id,
#define IS_EXPANDED_RESPONSE(id, t) \
(type == EAP_TYPE_EXPANDED && vendor_id == (id) && vendor_type == (t))
+#define RESPONSE_IS(t) \
+ (type == (t) || IS_EXPANDED_RESPONSE(0, (t)))
+
static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
size_t len)
{
@@ -428,14 +431,6 @@ static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
eap->method->vendor_id[2];
uint32_t our_vendor_type = eap->method->vendor_type;
- bool response_is(enum eap_type wanted)
- {
- if (type == wanted)
- return true;
-
- return IS_EXPANDED_RESPONSE(0, wanted);
- }
-
if (len < 1)
/* Invalid packets to be ignored */
return;
@@ -461,7 +456,7 @@ static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
return;
}
- if (response_is(EAP_TYPE_NAK)) {
+ if (RESPONSE_IS(EAP_TYPE_NAK)) {
l_debug("EAP peer not configured for method: %s",
eap_type_to_str(our_type, our_vendor_id,
our_vendor_type));
@@ -500,7 +495,7 @@ static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
*/
if (!eap->identity) {
- if (!response_is(EAP_TYPE_IDENTITY))
+ if (!RESPONSE_IS(EAP_TYPE_IDENTITY))
goto unsupported_method;
/*
@@ -528,7 +523,7 @@ static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
* (with the exception of the Nak)
*/
if (our_type != EAP_TYPE_EXPANDED) {
- if (response_is(our_type))
+ if (RESPONSE_IS(our_type))
goto handle_response;
} else if (IS_EXPANDED_RESPONSE(our_vendor_id, our_vendor_type))
goto handle_response;
--
2.33.0
6 months, 1 week
[PATCH] station: Prevent a NULL pointer access
by Torsten Schmitz
There is an unchecked NULL pointer access in network_has_open_pair.
open_info can definitely be NULL, I have the coredumps to prove it.
Let's check owe_info too though.
---
src/station.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/station.c b/src/station.c
index 19f2aaeb..75ec36df 100644
--- a/src/station.c
+++ b/src/station.c
@@ -693,11 +693,17 @@ static bool network_has_open_pair(struct network *network, struct scan_bss *owe)
const struct l_queue_entry *entry;
struct ie_owe_transition_info *owe_info = owe->owe_trans;
+ if (!owe_info)
+ return false;
+
for (entry = network_bss_list_get_entries(network); entry;
entry = entry->next) {
struct scan_bss *open = entry->data;
struct ie_owe_transition_info *open_info = open->owe_trans;
+ if (!open_info)
+ continue;
+
/*
* Check if this is an Open/Hidden pair:
*
--
2.33.1
6 months, 1 week
[PATCH 1/5] scan: parse Proxy ARP bit from extended capabilities
by James Prestwood
---
src/scan.c | 17 +++++++++++++++++
src/scan.h | 1 +
2 files changed, 18 insertions(+)
diff --git a/src/scan.c b/src/scan.c
index be5953ad..2a96943b 100644
--- a/src/scan.c
+++ b/src/scan.c
@@ -1252,6 +1252,23 @@ static bool scan_parse_bss_information_elements(struct scan_bss *bss,
bss->rc_ie = l_memdup(iter.data - 2, iter.len + 2);
break;
+
+ case IE_TYPE_EXTENDED_CAPABILITIES:
+ /* 802.11-2020 9.4.2.26
+ *
+ * "The length of the Extended Capabilities field is
+ * variable. If fewer bits are received in an Extended
+ * Capabilities field than shown in Table 9-153, the
+ * rest of the Extended Capabilities field bits are
+ * assumed to be zero"
+ *
+ * Currently only Proxy ARP bit (12) is checked, and if
+ * not found, this is not a fatal error.
+ */
+ if (iter.len < 2)
+ break;
+
+ bss->proxy_arp = test_bit(iter.data, 12);
}
}
diff --git a/src/scan.h b/src/scan.h
index 22981585..0378ccca 100644
--- a/src/scan.h
+++ b/src/scan.h
@@ -86,6 +86,7 @@ struct scan_bss {
bool anqp_capable : 1;
bool hs20_capable : 1;
bool force_default_sae_group : 1;
+ bool proxy_arp : 1;
uint8_t cost_level : 3;
uint8_t cost_flags : 4;
};
--
2.31.1
6 months, 2 weeks
[PATCH 1/4] sysfs: introduce sysfs module
by James Prestwood
Netconfig was the only user of sysfs but now other modules will
also need it.
Adding existing API for IPv6 settings, a IPv4 and IPv6 'supports'
checker, and a setter for IPv4 settings.
---
Makefile.am | 1 +
src/sysfs.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/sysfs.h | 28 ++++++++++++++
3 files changed, 138 insertions(+)
create mode 100644 src/sysfs.c
create mode 100644 src/sysfs.h
diff --git a/Makefile.am b/Makefile.am
index a6dafe63..275dd1b9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -246,6 +246,7 @@ src_iwd_SOURCES = src/main.c linux/nl80211.h src/iwd.h src/missing.h \
src/diagnostic.h src/diagnostic.c \
src/ip-pool.h src/ip-pool.c \
src/band.h src/band.c \
+ src/sysfs.h src/sysfs.c \
$(eap_sources) \
$(builtin_sources)
diff --git a/src/sysfs.c b/src/sysfs.c
new file mode 100644
index 00000000..d7972fc4
--- /dev/null
+++ b/src/sysfs.c
@@ -0,0 +1,109 @@
+/*
+ *
+ * Wireless daemon for Linux
+ *
+ * Copyright (C) 2021 Intel Corporation. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <sys/stat.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <ell/ell.h>
+
+#include "src/sysfs.h"
+
+static int write_string(const char *file, const char *value)
+{
+ size_t l = strlen(value);
+ int fd;
+ int r;
+
+ fd = L_TFR(open(file, O_WRONLY));
+ if (fd < 0)
+ return -errno;
+
+ r = L_TFR(write(fd, value, l));
+ L_TFR(close(fd));
+
+ return r;
+}
+
+static bool sysfs_supports_ip_setting(const char *ipv, const char *ifname,
+ const char *setting)
+{
+ struct stat st;
+ int err;
+ L_AUTO_FREE_VAR(char *, file) =
+ l_strdup_printf("/proc/sys/net/%s/conf/%s/%s", ipv,
+ ifname, setting);
+
+ err = stat(file, &st);
+
+ if (!err && S_ISREG(st.st_mode) != 0)
+ return true;
+
+ return false;
+}
+
+bool sysfs_supports_ipv6_setting(const char *ifname, const char *setting)
+{
+ return sysfs_supports_ip_setting("ipv6", ifname, setting);
+}
+
+int sysfs_write_ipv6_setting(const char *ifname, const char *setting,
+ const char *value)
+{
+ int r;
+
+ L_AUTO_FREE_VAR(char *, file) =
+ l_strdup_printf("/proc/sys/net/ipv6/conf/%s/%s",
+ ifname, setting);
+
+ r = write_string(file, value);
+ if (r < 0)
+ l_error("Unable to write %s to %s", setting, file);
+
+ return r;
+}
+
+bool sysfs_supports_ipv4_setting(const char *ifname, const char *setting)
+{
+ return sysfs_supports_ip_setting("ipv4", ifname, setting);
+}
+
+int sysfs_write_ipv4_setting(const char *ifname, const char *setting,
+ const char *value)
+{
+ int r;
+
+ L_AUTO_FREE_VAR(char *, file) =
+ l_strdup_printf("/proc/sys/net/ipv4/conf/%s/%s",
+ ifname, setting);
+
+ r = write_string(file, value);
+ if (r < 0)
+ l_error("Unable to write %s to %s", setting, file);
+
+ return r;
+}
diff --git a/src/sysfs.h b/src/sysfs.h
new file mode 100644
index 00000000..60207c13
--- /dev/null
+++ b/src/sysfs.h
@@ -0,0 +1,28 @@
+/*
+ *
+ * Wireless daemon for Linux
+ *
+ * Copyright (C) 2021 Intel Corporation. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+bool sysfs_supports_ipv6_setting(const char *ifname, const char *setting);
+int sysfs_write_ipv6_setting(const char *ifname, const char *setting,
+ const char *value);
+bool sysfs_supports_ipv4_setting(const char *ifname, const char *setting);
+int sysfs_write_ipv4_setting(const char *ifname, const char *setting,
+ const char *value);
--
2.31.1
6 months, 2 weeks
word wrap in man iwd.config
by Andrej Surkov
Hi,
yesterday I've tried for search manpage man iwd.config with keywork
'disconnect' ... and failed due to word wraps! The word 'disconnect' is
there, two times, but it is wrapped with - sign both occurances. That's
weird!
thank you anyway,
Andrej
6 months, 2 weeks