AP: Warn about VLAN interface name truncations

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
This commit is contained in:
Andrei Otcheretianski 2018-08-22 20:47:32 +03:00 committed by Jouni Malinen
parent d577f7f3d5
commit 68500d8159

View file

@ -138,6 +138,8 @@ int vlan_init(struct hostapd_data *hapd)
!hapd->conf->vlan) { !hapd->conf->vlan) {
/* dynamic vlans enabled but no (or empty) vlan_file given */ /* dynamic vlans enabled but no (or empty) vlan_file given */
struct hostapd_vlan *vlan; struct hostapd_vlan *vlan;
int ret;
vlan = os_zalloc(sizeof(*vlan)); vlan = os_zalloc(sizeof(*vlan));
if (vlan == NULL) { if (vlan == NULL) {
wpa_printf(MSG_ERROR, "Out of memory while assigning " wpa_printf(MSG_ERROR, "Out of memory while assigning "
@ -146,8 +148,16 @@ int vlan_init(struct hostapd_data *hapd)
} }
vlan->vlan_id = VLAN_ID_WILDCARD; vlan->vlan_id = VLAN_ID_WILDCARD;
os_snprintf(vlan->ifname, sizeof(vlan->ifname), "%s.#", ret = os_snprintf(vlan->ifname, sizeof(vlan->ifname), "%s.#",
hapd->conf->iface); hapd->conf->iface);
if (ret >= (int) sizeof(vlan->ifname)) {
wpa_printf(MSG_WARNING,
"VLAN: Interface name was truncated to %s",
vlan->ifname);
} else if (ret < 0) {
os_free(vlan);
return ret;
}
vlan->next = hapd->conf->vlan; vlan->next = hapd->conf->vlan;
hapd->conf->vlan = vlan; hapd->conf->vlan = vlan;
} }