Skip to content

Commit fedcfb4

Browse files
lePicimichalvasko
authored andcommitted
messages server BUGFIX sequence of elements in rpc-error
The <error-message> element must come before the <error-info>, see appendix-B in RFC6241.
1 parent 4a7ba35 commit fedcfb4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/messages_server.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,13 @@ nc_err_set_msg(struct lyd_node *err, const char *error_message, const char *lang
581581

582582
NC_CHECK_ARG_RET(NULL, err, error_message, -1);
583583

584-
/* remove previous message */
585584
lyd_find_sibling_opaq_next(lyd_child(err), "error-message", &match);
586585
if (match) {
587-
lyd_free_tree(match);
586+
/* Change the value of error-message and keep order of elements to comply with appendix-B in RFC 6241. */
587+
lydict_remove(LYD_CTX(err), ((struct lyd_node_opaq *)match)->value);
588+
lydict_insert(LYD_CTX(err), error_message, 0, &(((struct lyd_node_opaq *)match)->value));
589+
return 0;
588590
}
589-
590591
if (lyd_new_opaq2(err, NULL, "error-message", error_message, NULL, NC_NS_BASE, &match)) {
591592
return -1;
592593
}

0 commit comments

Comments
 (0)