From: darkcoven Date: Sun, 22 Sep 2013 13:55:41 +0000 (+0200) Subject: Fix crash when writing the wrong type of VLAN X-Git-Url: https://git.sur5r.net/?p=ngadmin;a=commitdiff_plain;h=feb31655e052b00cfbad44f008c3133dd3e7a3b2 Fix crash when writing the wrong type of VLAN --- diff --git a/lib/src/vlan.c b/lib/src/vlan.c index 09d6850..d7aa9e5 100644 --- a/lib/src/vlan.c +++ b/lib/src/vlan.c @@ -356,11 +356,19 @@ int ngadmin_setVLANDotConf (struct ngadmin *nga, unsigned short vlan, const unsi filterAttributes(attr, ATTR_VLAN_DOT_CONF, ATTR_END); - if (attr->first != NULL) { + /* check if the switch is in 802.1Q mode */ + if (attr->first == NULL) { + ret = ERR_INVARG; + goto end; + } else { at = attr->first->data; - memcpy(avc, at->data, sizeof(struct attr_vlan_conf) + sa->ports); + if (at->size != sizeof(struct attr_vlan_conf) + sa->ports) { + ret = ERR_INVARG; + goto end; + } } + memcpy(avc, at->data, sizeof(struct attr_vlan_conf) + sa->ports); clearList(attr, (void(*)(void*))freeAttr); }