From feb31655e052b00cfbad44f008c3133dd3e7a3b2 Mon Sep 17 00:00:00 2001 From: darkcoven Date: Sun, 22 Sep 2013 15:55:41 +0200 Subject: [PATCH] Fix crash when writing the wrong type of VLAN --- lib/src/vlan.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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); } -- 2.39.2