]> pilppa.org Git - uci.git/blobdiff - ucimap.c
add sanity checks for optmap section type vs sectionmap type
[uci.git] / ucimap.c
index 6d97b070c7c2a986d3237c20e4f06c0988142ab8..9aafe0b1cc8cca5f5c16fc9e7953d71c39284b1d 100644 (file)
--- a/ucimap.c
+++ b/ucimap.c
@@ -439,6 +439,14 @@ ucimap_check_optmap_type(struct uci_sectionmap *sm, struct uci_optmap *om)
 {
        unsigned int type;
 
+       if (unlikely(sm->type_name != om->type_name) &&
+           unlikely(strcmp(sm->type_name, om->type_name) != 0)) {
+               DPRINTF("Option '%s' of section type '%s' refereces unknown "
+                       "section type '%s', should be '%s'.\n",
+                       om->name, sm->type, om->type_name, sm->type_name);
+               return false;
+       }
+
        if (om->detected_type < 0)
                return true;