Skip to content

Commit 7560ac4

Browse files
committed
yin parser BUGFIX correct leafref config check
Fixes CESNET/netopeer2#418
1 parent 358b995 commit 7560ac4

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

src/parser_yin.c

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,35 @@ fill_yin_type(struct lys_module *module, struct lys_node *parent, struct lyxml_e
13051305

13061306
/* RFC 6020 9.9.2 - path */
13071307
LY_TREE_FOR(yin->child, node) {
1308+
if (!strcmp(node->name, "path") && !type->der->type.der) {
1309+
/* keep path for later */
1310+
} else if (module->version >= 2 && !strcmp(node->name, "require-instance")) {
1311+
if (type->info.lref.req) {
1312+
LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
1313+
goto error;
1314+
}
1315+
GETVAL(ctx, value, node, "value");
1316+
if (!strcmp(value, "true")) {
1317+
type->info.lref.req = 1;
1318+
} else if (!strcmp(value, "false")) {
1319+
type->info.lref.req = -1;
1320+
} else {
1321+
LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
1322+
goto error;
1323+
}
1324+
1325+
/* extensions */
1326+
if (lyp_yin_parse_subnode_ext(module, type, LYEXT_PAR_TYPE, node, LYEXT_SUBSTMT_REQINSTANCE, 0, unres)) {
1327+
goto error;
1328+
}
1329+
} else {
1330+
LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
1331+
goto error;
1332+
}
1333+
}
13081334

1335+
/* now that require-instance is properly set, try to find and resolve path */
1336+
LY_TREE_FOR(yin->child, node) {
13091337
if (!strcmp(node->name, "path") && !type->der->type.der) {
13101338
if (type->info.lref.path) {
13111339
LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
@@ -1334,28 +1362,8 @@ fill_yin_type(struct lys_module *module, struct lys_node *parent, struct lyxml_e
13341362
if (lyp_yin_parse_subnode_ext(module, type, LYEXT_PAR_TYPE, node, LYEXT_SUBSTMT_PATH, 0, unres)) {
13351363
goto error;
13361364
}
1337-
} else if (module->version >= 2 && !strcmp(node->name, "require-instance")) {
1338-
if (type->info.lref.req) {
1339-
LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
1340-
goto error;
1341-
}
1342-
GETVAL(ctx, value, node, "value");
1343-
if (!strcmp(value, "true")) {
1344-
type->info.lref.req = 1;
1345-
} else if (!strcmp(value, "false")) {
1346-
type->info.lref.req = -1;
1347-
} else {
1348-
LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
1349-
goto error;
1350-
}
13511365

1352-
/* extensions */
1353-
if (lyp_yin_parse_subnode_ext(module, type, LYEXT_PAR_TYPE, node, LYEXT_SUBSTMT_REQINSTANCE, 0, unres)) {
1354-
goto error;
1355-
}
1356-
} else {
1357-
LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
1358-
goto error;
1366+
break;
13591367
}
13601368
}
13611369

0 commit comments

Comments
 (0)