[2/2] AP: Warn about VLAN interface name truncations

Message ID 1534960052-14229-2-git-send-email-andrei.otcheretianski@intel.com
State Accepted
Headers show
Series
  • [1/2] driver_nl80211: Warn about interface name truncations
Related show

Commit Message

Andrei Otcheretianski Aug. 22, 2018, 5:47 p.m.
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
---
 src/ap/vlan_init.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Patch

diff --git a/src/ap/vlan_init.c b/src/ap/vlan_init.c
index 31e4fc6..99f1e3f 100644
--- a/src/ap/vlan_init.c
+++ b/src/ap/vlan_init.c
@@ -138,6 +138,8 @@  int vlan_init(struct hostapd_data *hapd)
 	    !hapd->conf->vlan) {
 		/* dynamic vlans enabled but no (or empty) vlan_file given */
 		struct hostapd_vlan *vlan;
+		int ret;
+
 		vlan = os_zalloc(sizeof(*vlan));
 		if (vlan == NULL) {
 			wpa_printf(MSG_ERROR, "Out of memory while assigning "
@@ -146,8 +148,14 @@  int vlan_init(struct hostapd_data *hapd)
 		}
 
 		vlan->vlan_id = VLAN_ID_WILDCARD;
-		os_snprintf(vlan->ifname, sizeof(vlan->ifname), "%s.#",
-			    hapd->conf->iface);
+		ret = os_snprintf(vlan->ifname, sizeof(vlan->ifname), "%s.#",
+				  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)
+			return ret;
 		vlan->next = hapd->conf->vlan;
 		hapd->conf->vlan = vlan;
 	}