parsers BUGFIX check that state nodes have no configuration children
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 7f8bf97..6fdfba7 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -1052,6 +1052,7 @@
lys_node_unlink(child);
}
+ /* connect the child correctly */
if (!parent) {
if (module->data) {
module->data->prev->next = child;
@@ -1079,6 +1080,16 @@
parent->child->prev = iter;
}
+ /* check config value */
+ if (parent && !(parent->nodetype & (LYS_GROUPING | LYS_AUGMENT))) {
+ for (iter = child; iter && !(iter->nodetype & (LYS_NOTIF | LYS_INPUT | LYS_OUTPUT | LYS_RPC)); iter = iter->parent);
+ if (!iter && (parent->flags & LYS_CONFIG_R) && (child->flags & LYS_CONFIG_W)) {
+ LOGVAL(LYE_INARG, LY_VLOG_LYS, child, "true", "config");
+ LOGVAL(LYE_SPEC, LY_VLOG_LYS, child, "State nodes cannot have configuration nodes as children.");
+ return EXIT_FAILURE;
+ }
+ }
+
/* propagate information about status data presence */
if ((child->nodetype & (LYS_CONTAINER | LYS_CHOICE | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | LYS_ANYDATA)) &&
(child->flags & LYS_INCL_STATUS)) {