parser xml BUGFIX check for empty input
Refs cesnet/netopeer2#1201
@@ -979,6 +979,12 @@ lydxml_env_netconf_rpc(struct lyxml_ctx *xmlctx, struct lyd_node **envp, uint32_
assert(envp && !*envp);
+ if (xmlctx->status != LYXML_ELEMENT) {
+ /* nothing to parse */
+ assert(xmlctx->status == LYXML_END);
+ goto cleanup;
+ }
+
/* parse "rpc" */
r = lydxml_envelope(xmlctx, "rpc", "urn:ietf:params:xml:ns:netconf:base:1.0", 0, envp);
LY_CHECK_ERR_GOTO(r, rc = r, cleanup);
@@ -1027,6 +1033,12 @@ lydxml_env_netconf_notif(struct lyxml_ctx *xmlctx, struct lyd_node **envp, uint3
assert(envp && !*envp);
+ if (xmlctx->status != LYXML_ELEMENT) {
+ /* nothing to parse */
+ assert(xmlctx->status == LYXML_END);
+ goto cleanup;
+ }
+
/* parse "notification" */
r = lydxml_envelope(xmlctx, "notification", "urn:ietf:params:xml:ns:netconf:notification:1.0", 0, envp);
LY_CHECK_ERR_GOTO(r, rc = r, cleanup);
@@ -1453,6 +1465,12 @@ lydxml_env_netconf_reply(struct lyxml_ctx *xmlctx, struct lyd_node **envp, uint3
assert(envp && !*envp);
+ if (xmlctx->status != LYXML_ELEMENT) {
+ /* nothing to parse */
+ assert(xmlctx->status == LYXML_END);
+ goto cleanup;
+ }
+
/* parse "rpc-reply" */
r = lydxml_envelope(xmlctx, "rpc-reply", "urn:ietf:params:xml:ns:netconf:base:1.0", 0, envp);
LY_CHECK_ERR_GOTO(r, rc = r, cleanup);
