]> git.sur5r.net Git - ngadmin/commitdiff
Fix crash when writing the wrong type of VLAN
authordarkcoven <admin@darkcoven.tk>
Sun, 22 Sep 2013 13:55:41 +0000 (15:55 +0200)
committerdarkcoven <admin@darkcoven.tk>
Sun, 22 Sep 2013 13:55:41 +0000 (15:55 +0200)
lib/src/vlan.c

index 09d685017b53374cf751478480e6e9182327ec8a..d7aa9e5c2c59a0c33e41b2c52b16995fc2590112 100644 (file)
@@ -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);
        }