aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2019-01-01 17:38:58 (GMT)
committerJouni Malinen <j@w1.fi>2019-01-01 17:38:58 (GMT)
commitb2f1e5458b48001d3d20e58e8ebb07616501cab8 (patch)
treec5f9004e2abeaecd6f94a8fea3af209d6a2de07d /src
parent2ea1fce3d64481f1a766e4b1d63d74c8d93a42c1 (diff)
downloadhostap-b2f1e5458b48001d3d20e58e8ebb07616501cab8.zip
hostap-b2f1e5458b48001d3d20e58e8ebb07616501cab8.tar.gz
hostap-b2f1e5458b48001d3d20e58e8ebb07616501cab8.tar.bz2
hostap: Silence compiler warnings about IFNAMSIZ buffers
Report interface name truncation and reject such cases in Host AP driver initialization of the AP interface. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src')
-rw-r--r--src/drivers/driver_hostap.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/drivers/driver_hostap.c b/src/drivers/driver_hostap.c
index 597da33..3f33bb5 100644
--- a/src/drivers/driver_hostap.c
+++ b/src/drivers/driver_hostap.c
@@ -231,7 +231,11 @@ 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);
+ if (os_snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%sap",
+ drv->iface) >= (int) sizeof(ifr.ifr_name)) {
+ wpa_printf(MSG_ERROR, "hostap: AP interface name truncated");
+ return -1;
+ }
if (ioctl(drv->sock, SIOCGIFINDEX, &ifr) != 0) {
wpa_printf(MSG_ERROR, "ioctl(SIOCGIFINDEX): %s",
strerror(errno));
@@ -348,7 +352,10 @@ static int hostap_set_iface_flags(void *priv, int dev_up)
struct ifreq ifr;
char ifname[IFNAMSIZ];
- os_snprintf(ifname, IFNAMSIZ, "%sap", drv->iface);
+ if (os_snprintf(ifname, IFNAMSIZ, "%sap", drv->iface) >= IFNAMSIZ) {
+ wpa_printf(MSG_ERROR, "hostap: AP interface name truncated");
+ return -1;
+ }
if (linux_set_iface_flags(drv->ioctl_sock, ifname, dev_up) < 0)
return -1;