aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2018-12-03 10:44:11 (GMT)
committerJouni Malinen <j@w1.fi>2018-12-03 10:44:11 (GMT)
commit9da196adf938c5bd4187b1d13538752802b8c090 (patch)
treef659a5232a4203fe1e4e8f217735ce0a13121f4e
parentf2973fa39d6109f0f34969e91551a98dc340d537 (diff)
downloadhostap-9da196adf938c5bd4187b1d13538752802b8c090.zip
hostap-9da196adf938c5bd4187b1d13538752802b8c090.tar.gz
hostap-9da196adf938c5bd4187b1d13538752802b8c090.tar.bz2
VLAN: Warn about interface name truncation
Add more snprintf checks to make it clearer if some of the ifname constructions would end up being too long. Signed-off-by: Jouni Malinen <j@w1.fi>
-rw-r--r--src/ap/vlan_full.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/ap/vlan_full.c b/src/ap/vlan_full.c
index aa42335..93cef95 100644
--- a/src/ap/vlan_full.c
+++ b/src/ap/vlan_full.c
@@ -363,12 +363,18 @@ static void vlan_newlink_tagged(int vlan_naming, const char *tagged_interface,
{
char vlan_ifname[IFNAMSIZ];
int clean;
+ int ret;
if (vlan_naming == DYNAMIC_VLAN_NAMING_WITH_DEVICE)
- os_snprintf(vlan_ifname, sizeof(vlan_ifname), "%s.%d",
- tagged_interface, vid);
+ ret = os_snprintf(vlan_ifname, sizeof(vlan_ifname), "%s.%d",
+ tagged_interface, vid);
else
- os_snprintf(vlan_ifname, sizeof(vlan_ifname), "vlan%d", vid);
+ ret = os_snprintf(vlan_ifname, sizeof(vlan_ifname), "vlan%d",
+ vid);
+ if (ret >= (int) sizeof(vlan_ifname))
+ wpa_printf(MSG_WARNING,
+ "VLAN: Interface name was truncated to %s",
+ vlan_ifname);
clean = 0;
ifconfig_up(tagged_interface);
@@ -387,16 +393,21 @@ static void vlan_newlink_tagged(int vlan_naming, const char *tagged_interface,
static void vlan_bridge_name(char *br_name, struct hostapd_data *hapd, int vid)
{
char *tagged_interface = hapd->conf->ssid.vlan_tagged_interface;
+ int ret;
if (hapd->conf->vlan_bridge[0]) {
- os_snprintf(br_name, IFNAMSIZ, "%s%d",
- hapd->conf->vlan_bridge, vid);
+ ret = os_snprintf(br_name, IFNAMSIZ, "%s%d",
+ hapd->conf->vlan_bridge, vid);
} else if (tagged_interface) {
- os_snprintf(br_name, IFNAMSIZ, "br%s.%d",
- tagged_interface, vid);
+ ret = os_snprintf(br_name, IFNAMSIZ, "br%s.%d",
+ tagged_interface, vid);
} else {
- os_snprintf(br_name, IFNAMSIZ, "brvlan%d", vid);
+ ret = os_snprintf(br_name, IFNAMSIZ, "brvlan%d", vid);
}
+ if (ret >= IFNAMSIZ)
+ wpa_printf(MSG_WARNING,
+ "VLAN: Interface name was truncated to %s",
+ br_name);
}
@@ -474,12 +485,19 @@ static void vlan_dellink_tagged(int vlan_naming, const char *tagged_interface,
{
char vlan_ifname[IFNAMSIZ];
int clean;
+ int ret;
if (vlan_naming == DYNAMIC_VLAN_NAMING_WITH_DEVICE)
- os_snprintf(vlan_ifname, sizeof(vlan_ifname), "%s.%d",
- tagged_interface, vid);
+ ret = os_snprintf(vlan_ifname, sizeof(vlan_ifname), "%s.%d",
+ tagged_interface, vid);
else
- os_snprintf(vlan_ifname, sizeof(vlan_ifname), "vlan%d", vid);
+ ret = os_snprintf(vlan_ifname, sizeof(vlan_ifname), "vlan%d",
+ vid);
+ if (ret >= (int) sizeof(vlan_ifname))
+ wpa_printf(MSG_WARNING,
+ "VLAN: Interface name was truncated to %s",
+ vlan_ifname);
+
clean = dyn_iface_put(hapd, vlan_ifname);