parser BUGFIX config deviation add/replace checks
Fixes #991
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 1deb978..6a71b92 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -2432,6 +2432,14 @@
/* del config is forbidden */
LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "config", "deviate delete");
goto error;
+ } else if ((d->mod == LY_DEVIATE_ADD) && (dev_target->flags & LYS_CONFIG_SET)) {
+ LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "config");
+ LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Adding property that already exists.");
+ goto error;
+ } else if ((d->mod == LY_DEVIATE_RPL) && !(dev_target->flags & LYS_CONFIG_SET)) {
+ LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "config");
+ LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Replacing a property that does not exist.");
+ goto error;
} else { /* add and replace are the same in this case */
/* remove current config value of the target ... */
dev_target->flags &= ~LYS_CONFIG_MASK;