File iwd-GNU_SOURCE.patch of Package iwd
diff --git a/client/dpp.c b/client/dpp.c
index a659f545..c160ac95 100644
--- a/client/dpp.c
+++ b/client/dpp.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <stdio.h>
#include <linux/limits.h>
diff --git a/client/known-networks.c b/client/known-networks.c
index 8634aca2..f9063786 100644
--- a/client/known-networks.c
+++ b/client/known-networks.c
@@ -279,35 +279,35 @@ static const struct proxy_interface *known_network_proxy_find_by_name(
struct network_args network_args;
struct l_queue *match;
const struct proxy_interface *proxy;
+ size_t name_len;
+ char *args_name;
if (!name)
return NULL;
- if (l_str_has_suffix(name, ".psk"))
+ name_len = strlen(name);
+
+ if (l_str_has_suffix(name, ".psk")) {
network_args.type = "psk";
- else if (l_str_has_suffix(name, ".8021x"))
+ name_len -= 4;
+ } else if (l_str_has_suffix(name, ".8021x")) {
network_args.type = "8021x";
- else if (l_str_has_suffix(name, ".open"))
+ name_len -= 6;
+ } else if (l_str_has_suffix(name, ".open")) {
network_args.type = "open";
- else
+ name_len -= 5;
+ } else
network_args.type = NULL;
- if (network_args.type) {
- char *dot = strrchr(name, '.');
-
- if (!dot)
- /* This shouldn't ever be the case */
- return NULL;
-
- *dot = '\0';
- }
-
- network_args.name = name;
+ args_name = l_strndup(name, name_len);
+ network_args.name = args_name;
match = proxy_interface_find_all(known_network_interface_type.interface,
known_network_match,
&network_args);
+ l_free(args_name);
+
if (!match) {
display("No network with specified parameters was found\n");
return NULL;
diff --git a/src/ap.c b/src/ap.c
index af6a1709..416e1104 100644
--- a/src/ap.c
+++ b/src/ap.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <errno.h>
#include <linux/if_ether.h>
#include <netinet/in.h>
diff --git a/src/crypto.c b/src/crypto.c
index 9dcdb43b..d9a9aaf3 100644
--- a/src/crypto.c
+++ b/src/crypto.c
@@ -26,6 +26,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <stdbool.h>
#include <string.h>
#include <errno.h>
diff --git a/src/dpp.c b/src/dpp.c
index ac56e55d..aa5f7e71 100644
--- a/src/dpp.c
+++ b/src/dpp.c
@@ -24,7 +24,9 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <errno.h>
+#include <string.h>
#include <ell/ell.h>
diff --git a/src/eap-aka.c b/src/eap-aka.c
index 9b693875..865f4181 100644
--- a/src/eap-aka.c
+++ b/src/eap-aka.c
@@ -24,9 +24,11 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <ctype.h>
#include <stdio.h>
#include <errno.h>
+#include <string.h>
#include <ell/ell.h>
#include "src/missing.h"
diff --git a/src/eap-gtc.c b/src/eap-gtc.c
index 4d2d67ab..80a857cb 100644
--- a/src/eap-gtc.c
+++ b/src/eap-gtc.c
@@ -24,8 +24,10 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
+#include <string.h>
#include <ell/ell.h>
#include "src/missing.h"
diff --git a/src/eap-md5.c b/src/eap-md5.c
index fcca550c..5cd0e01c 100644
--- a/src/eap-md5.c
+++ b/src/eap-md5.c
@@ -24,8 +24,10 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
+#include <string.h>
#include <ell/ell.h>
#include "src/missing.h"
diff --git a/src/eap-mschapv2.c b/src/eap-mschapv2.c
index 00976d73..cfe4593b 100644
--- a/src/eap-mschapv2.c
+++ b/src/eap-mschapv2.c
@@ -24,9 +24,11 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <ctype.h>
#include <stdio.h>
#include <errno.h>
+#include <string.h>
#include <ell/ell.h>
#include "src/missing.h"
diff --git a/src/eap-peap.c b/src/eap-peap.c
index 785bfc81..45590668 100644
--- a/src/eap-peap.c
+++ b/src/eap-peap.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <string.h>
#include <stdio.h>
#include <errno.h>
diff --git a/src/eap-pwd.c b/src/eap-pwd.c
index 5aa51668..7e75a1a2 100644
--- a/src/eap-pwd.c
+++ b/src/eap-pwd.c
@@ -24,7 +24,9 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <stdio.h>
+#include <string.h>
#include <ell/ell.h>
diff --git a/src/eap-sim.c b/src/eap-sim.c
index 93063b7a..83f2debf 100644
--- a/src/eap-sim.c
+++ b/src/eap-sim.c
@@ -24,10 +24,12 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <ctype.h>
#include <stdio.h>
#include <errno.h>
#include <alloca.h>
+#include <string.h>
#include <ell/ell.h>
#include "src/missing.h"
diff --git a/src/eap-tls.c b/src/eap-tls.c
index 56fdc67f..1cf94a5c 100644
--- a/src/eap-tls.c
+++ b/src/eap-tls.c
@@ -24,9 +24,11 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <string.h>
#include <stdio.h>
#include <errno.h>
+#include <alloca.h>
#include <ell/ell.h>
#include "src/missing.h"
diff --git a/src/eap-ttls.c b/src/eap-ttls.c
index 43a6c118..3ccd1dd1 100644
--- a/src/eap-ttls.c
+++ b/src/eap-ttls.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <string.h>
#include <stdio.h>
#include <errno.h>
diff --git a/src/eap-wsc.c b/src/eap-wsc.c
index 4e940bf8..0a071967 100644
--- a/src/eap-wsc.c
+++ b/src/eap-wsc.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <string.h>
#include <stdio.h>
#include <errno.h>
diff --git a/src/eapol.c b/src/eapol.c
index ab77746f..372549c6 100644
--- a/src/eapol.c
+++ b/src/eapol.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <string.h>
#include <alloca.h>
#include <linux/if_ether.h>
diff --git a/src/erp.c b/src/erp.c
index 05d1b3e2..ae09983f 100644
--- a/src/erp.c
+++ b/src/erp.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <stdint.h>
#include <stdio.h>
#include <errno.h>
diff --git a/src/fils.c b/src/fils.c
index ff8c1d6c..69346ed1 100644
--- a/src/fils.c
+++ b/src/fils.c
@@ -25,6 +25,8 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
+#include <stdlib.h>
#include <ell/ell.h>
#include "ell/useful.h"
diff --git a/src/ft.c b/src/ft.c
index 0d6be4d4..c646ef8a 100644
--- a/src/ft.c
+++ b/src/ft.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#include <alloca.h>
#include <ell/ell.h>
#include "src/ie.h"
diff --git a/src/handshake.c b/src/handshake.c
index ef1a8220..f6b16c31 100644
--- a/src/handshake.c
+++ b/src/handshake.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <string.h>
#include <unistd.h>
#include <errno.h>
diff --git a/src/hotspot.c b/src/hotspot.c
index 89b3095f..3e7c3ee4 100644
--- a/src/hotspot.c
+++ b/src/hotspot.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <dirent.h>
#include <errno.h>
#include <stdio.h>
diff --git a/src/knownnetworks.c b/src/knownnetworks.c
index 6f65d2b3..886f8145 100644
--- a/src/knownnetworks.c
+++ b/src/knownnetworks.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
diff --git a/src/mschaputil.c b/src/mschaputil.c
index 7a4927ba..165d1c89 100644
--- a/src/mschaputil.c
+++ b/src/mschaputil.c
@@ -24,6 +24,9 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
+#include <string.h>
+
#include <ell/ell.h>
#include "src/missing.h"
diff --git a/src/netconfig.c b/src/netconfig.c
index cd19217c..4e62b1dc 100644
--- a/src/netconfig.c
+++ b/src/netconfig.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <errno.h>
#include <arpa/inet.h>
#include <net/if_arp.h>
@@ -31,6 +32,7 @@
#include <limits.h>
#include <string.h>
#include <fcntl.h>
+#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
diff --git a/src/netdev.c b/src/netdev.c
index cdb3f1d7..e639a1f8 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <stdlib.h>
#include <alloca.h>
#include <stdio.h>
@@ -32,8 +33,8 @@
#include <linux/if.h>
#include <linux/if_packet.h>
#include <linux/if_ether.h>
-#include <arpa/inet.h>
#include <linux/filter.h>
+#include <arpa/inet.h>
#include <sys/socket.h>
#include <errno.h>
diff --git a/src/network.c b/src/network.c
index 588ea5ae..a5a2375a 100644
--- a/src/network.c
+++ b/src/network.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
diff --git a/src/p2p.c b/src/p2p.c
index 7d89da21..33a4269f 100644
--- a/src/p2p.c
+++ b/src/p2p.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <stdlib.h>
#include <linux/rtnetlink.h>
#include <linux/if_ether.h>
@@ -35,6 +36,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <linux/if.h>
+#include <sys/param.h>
#include <ell/ell.h>
diff --git a/src/resolve.c b/src/resolve.c
index 6ce3fa7d..d29cbbdb 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <errno.h>
#include <arpa/inet.h>
#include <sys/stat.h>
diff --git a/src/rfkill.c b/src/rfkill.c
index 0c88b3ea..eb3567fc 100644
--- a/src/rfkill.c
+++ b/src/rfkill.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
diff --git a/src/simutil.c b/src/simutil.c
index 8947ad66..69a5ad5e 100644
--- a/src/simutil.c
+++ b/src/simutil.c
@@ -24,9 +24,11 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <ctype.h>
#include <stdio.h>
#include <errno.h>
+#include <string.h>
#include <ell/ell.h>
#include "src/missing.h"
diff --git a/src/udev.c b/src/udev.c
index 859f00bd..d8adbf0f 100644
--- a/src/udev.c
+++ b/src/udev.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <errno.h>
#include <unistd.h>
#include <sys/socket.h>
diff --git a/src/wsc.c b/src/wsc.c
index 44b8d3de..bca68ae2 100644
--- a/src/wsc.c
+++ b/src/wsc.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <errno.h>
#include <stdio.h>
#include <ell/ell.h>
diff --git a/src/wscutil.c b/src/wscutil.c
index 570c4d66..e273f935 100644
--- a/src/wscutil.c
+++ b/src/wscutil.c
@@ -28,6 +28,7 @@
#include <stdarg.h>
#include <errno.h>
#include <stdio.h>
+#include <strings.h>
#include <ell/ell.h>
diff --git a/tools/probe-req.c b/tools/probe-req.c
index 7ec8e3af..86fe48ee 100644
--- a/tools/probe-req.c
+++ b/tools/probe-req.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
diff --git a/unit/test-sae.c b/unit/test-sae.c
index b4319f5e..00ac5b3d 100644
--- a/unit/test-sae.c
+++ b/unit/test-sae.c
@@ -25,6 +25,7 @@
#endif
#include <string.h>
+#include <alloca.h>
#include <assert.h>
#include <ell/ell.h>
diff --git a/wired/ethdev.c b/wired/ethdev.c
index ed128006..29ea6264 100644
--- a/wired/ethdev.c
+++ b/wired/ethdev.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <unistd.h>