]> git.sur5r.net Git - ngadmin/blobdiff - lib/src/network.c
Lib: add size checks to prevent several crashes
[ngadmin] / lib / src / network.c
index 8f26fc921a010e71dbeddce811b00d2c52fcfd44..3f3126bc304301362c0fe2ec1aea127068e1ec0e 100644 (file)
@@ -314,7 +314,7 @@ end:
 }
 
 
-void extractSwitchAttributes (struct swi_attr *sa, const List *l)
+int extractSwitchAttributes (struct swi_attr *sa, const List *l)
 {
        const ListNode *ln;
        const struct attr *at;
@@ -325,6 +325,8 @@ void extractSwitchAttributes (struct swi_attr *sa, const List *l)
        
        for (ln = l->first; ln != NULL; ln = ln->next) {
                at = ln->data;
+               if (at->size == 0)
+                       return -EMSGSIZE;
                
                switch (at->attr) {
                
@@ -374,9 +376,12 @@ void extractSwitchAttributes (struct swi_attr *sa, const List *l)
                        break;
                
                case ATTR_END:
-                       return;
+                       return 0;
                }
        }
+       
+       
+       return 0;
 }