#ifndef BOND_MAX_ARP_TARGETS
#define BOND_MAX_ARP_TARGETS 16
#endif
+
+/* Not exposed but defined in include/linux/ieee80211.h */
+#ifndef IEEE80211_MAX_SSID_LEN
+#define IEEE80211_MAX_SSID_LEN 32
+#endif
#include <linux/nl80211.h>
#include <linux/wireguard.h>
+#include "missing_network.h"
#include "netlink-genl.h"
#include "netlink-types-internal.h"
static const NLType genl_nl80211_types[] = {
[NL80211_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 },
[NL80211_ATTR_MAC] = { .type = NETLINK_TYPE_ETHER_ADDR },
- [NL80211_ATTR_SSID] = { .type = NETLINK_TYPE_STRING },
+ [NL80211_ATTR_SSID] = { .type = NETLINK_TYPE_BINARY, .size = IEEE80211_MAX_SSID_LEN },
[NL80211_ATTR_IFTYPE] = { .type = NETLINK_TYPE_U32 },
};
_cleanup_free_ char *ssid = NULL;
const char *family;
uint32_t iftype;
+ size_t len;
int r;
assert(genl);
if (r < 0)
return log_debug_errno(r, "Failed to get NL80211_ATTR_IFTYPE attribute: %m");
- r = sd_netlink_message_read_string_strdup(reply, NL80211_ATTR_SSID, &ssid);
+ r = sd_netlink_message_read_data_suffix0(reply, NL80211_ATTR_SSID, &len, (void**) &ssid);
if (r < 0 && r != -ENODATA)
return log_debug_errno(r, "Failed to get NL80211_ATTR_SSID attribute: %m");
+ if (r >= 0) {
+ if (len == 0) {
+ log_debug("SSID has zero length, ignoring the received SSID.");
+ ssid = mfree(ssid);
+ } else if (strlen_ptr(ssid) != len) {
+ log_debug("SSID contains NUL character(s), ignoring the received SSID.");
+ ssid = mfree(ssid);
+ }
+ }
if (ret_iftype)
*ret_iftype = iftype;