Filter duplicate NETCONF requests on the same object causing memory fault

This commit is contained in:
Olof hagsand 2024-05-27 14:09:04 +02:00
parent 1904805103
commit 1412b416f6
2 changed files with 30 additions and 1 deletions

View file

@ -495,6 +495,7 @@ text_modify(clixon_handle h,
yang_stmt *yc; /* yang child */ yang_stmt *yc; /* yang child */
cxobj **x0vec = NULL; cxobj **x0vec = NULL;
int i; int i;
int j;
int ret; int ret;
char *instr = NULL; char *instr = NULL;
char *keystr = NULL; char *keystr = NULL;
@ -921,8 +922,16 @@ text_modify(clixon_handle h,
x0c = NULL; x0c = NULL;
if (match_base_child(x0, x1c, yc, &x0c) < 0) if (match_base_child(x0, x1c, yc, &x0c) < 0)
goto done; goto done;
if (x0c) {
/* Duplicate check can happen if multiple operations on same object, whihc should be filtered, just silently drop */
for (j=0; j<i; j++)
if (x0vec[j] == x0c)
break;
if (j==i)
x0vec[i++] = x0c; /* != NULL if x0c is matching x1c */ x0vec[i++] = x0c; /* != NULL if x0c is matching x1c */
} }
}
/* Second pass: Loop through children of the x1 modification tree again /* Second pass: Loop through children of the x1 modification tree again
* Now potentially modify x0:s children * Now potentially modify x0:s children
* Here x0vec contains one-to-one matching nodes of x1:s children. * Here x0vec contains one-to-one matching nodes of x1:s children.

View file

@ -66,6 +66,26 @@ fi
new "wait backend" new "wait backend"
wait_backend wait_backend
new "Add list entry"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><default-operation>merge</default-operation><config><c xmlns=\"urn:example:clixon\" xmlns:nc=\"${BASENS}\">
<server>
<name>one</name>
<value>foo</value>
</server>
</c></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "Add duplicate list entries"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><default-operation>none</default-operation><config><c xmlns=\"urn:example:clixon\" xmlns:nc=\"${BASENS}\">
<server nc:operation=\"replace\">
<name>one</name>
<value>bar</value>
</server>
<server nc:operation=\"replace\">
<name>one</name>
<value>fie</value>
</server>
</c></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>operation-failed</error-tag><error-app-tag>data-not-unique</error-app-tag><error-severity>error</error-severity><error-info><non-unique xmlns=\"urn:ietf:params:xml:ns:yang:1\">/rpc/edit-config/config/c/server[name=\"one\"]/name</non-unique></error-info></rpc-error></rpc-reply>"
new "Add list with duplicate" new "Add list with duplicate"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><default-operation>replace</default-operation><config><c xmlns=\"urn:example:clixon\"> expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><default-operation>replace</default-operation><config><c xmlns=\"urn:example:clixon\">
<server> <server>