[PATCH] Hacks to build on Fedora-26.

greearb at candelatech.com greearb at candelatech.com
Wed Sep 6 13:58:34 PDT 2017


From: Ben Greear <greearb at candelatech.com>

The compiler on Fedora-26 has gotten pickier about some things.
The issues it complains about seem real, but I guess they do not
happen in practice or someone one have noticed already.

Signed-off-by: Ben Greear <greearb at candelatech.com>
---
 src/drivers/driver_hostap.c          | 11 ++++++++---
 src/drivers/driver_nl80211.c         |  5 ++++-
 src/drivers/driver_nl80211_monitor.c |  4 ++--
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/drivers/driver_hostap.c b/src/drivers/driver_hostap.c
index 597da335e..218020250 100644
--- a/src/drivers/driver_hostap.c
+++ b/src/drivers/driver_hostap.c
@@ -217,6 +217,7 @@ static int hostap_init_sockets(struct hostap_driver_data *drv, u8 *own_addr)
 {
 	struct ifreq ifr;
 	struct sockaddr_ll addr;
+	char buf[32];
 
 	drv->sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
 	if (drv->sock < 0) {
@@ -231,7 +232,9 @@ static int hostap_init_sockets(struct hostap_driver_data *drv, u8 *own_addr)
 	}
 
         memset(&ifr, 0, sizeof(ifr));
-        snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%sap", drv->iface);
+        snprintf(buf, sizeof(buf), "%sap", drv->iface);
+        os_strlcpy(ifr.ifr_name, buf, sizeof(ifr.ifr_name));
+
         if (ioctl(drv->sock, SIOCGIFINDEX, &ifr) != 0) {
 		wpa_printf(MSG_ERROR, "ioctl(SIOCGIFINDEX): %s",
 			   strerror(errno));
@@ -346,9 +349,11 @@ static int hostap_set_iface_flags(void *priv, int dev_up)
 {
 	struct hostap_driver_data *drv = priv;
 	struct ifreq ifr;
-	char ifname[IFNAMSIZ];
+	char ifname[IFNAMSIZ + 10];
+
+	os_snprintf(ifname, sizeof(ifname), "%sap", drv->iface);
+	ifname[IFNAMSIZ - 1] = 0;
 
-	os_snprintf(ifname, IFNAMSIZ, "%sap", drv->iface);
 	if (linux_set_iface_flags(drv->ioctl_sock, ifname, dev_up) < 0)
 		return -1;
 
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 0271f960c..ffec533e1 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -6398,8 +6398,11 @@ static int i802_set_wds_sta(void *priv, const u8 *addr, int aid, int val,
 	struct i802_bss *bss = priv;
 	struct wpa_driver_nl80211_data *drv = bss->drv;
 	char name[IFNAMSIZ + 1];
+	char tmp[34]; /* make F-26 gcc stop complaining about size of snprintf destination */
+
+	os_snprintf(tmp, sizeof(tmp), "%s.sta%d", bss->ifname, aid);
+	os_strlcpy(name, tmp, sizeof(name));
 
-	os_snprintf(name, sizeof(name), "%s.sta%d", bss->ifname, aid);
 	if (ifname_wds)
 		os_strlcpy(ifname_wds, name, IFNAMSIZ + 1);
 
diff --git a/src/drivers/driver_nl80211_monitor.c b/src/drivers/driver_nl80211_monitor.c
index 28a99f274..e7ea023a2 100644
--- a/src/drivers/driver_nl80211_monitor.c
+++ b/src/drivers/driver_nl80211_monitor.c
@@ -340,7 +340,7 @@ void nl80211_remove_monitor_interface(struct wpa_driver_nl80211_data *drv)
 
 int nl80211_create_monitor_interface(struct i802_bss *bss, struct wpa_driver_nl80211_data *drv)
 {
-	char buf[IFNAMSIZ];
+	char buf[IFNAMSIZ + 20];
 	struct sockaddr_ll ll;
 	int optval;
 	socklen_t optlen;
@@ -362,7 +362,7 @@ int nl80211_create_monitor_interface(struct i802_bss *bss, struct wpa_driver_nl8
 		snprintf(buf, IFNAMSIZ, "mon-%s", drv->first_bss->ifname + 4);
 	} else {
 		/* Non-P2P interface with AP functionality. */
-		snprintf(buf, IFNAMSIZ, "mon.%s", drv->first_bss->ifname);
+		snprintf(buf, sizeof(buf), "mon.%s", drv->first_bss->ifname);
 	}
 
 	buf[IFNAMSIZ - 1] = '\0';
-- 
2.13.5




More information about the Hostap mailing list