Skip to content

Commit e2064d6

Browse files
committed
Fixed: segv when controller connecting to devices with dangling config
1 parent 02c9d32 commit e2064d6

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

lib/src/clixon_xml_diff.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ diff_rebase_exec(diff_rebase_t *dr)
924924
*
925925
* @param[in] x0 XML object 0
926926
* @param[in] x1 XML object 1
927-
* @param[out] eq 0: equal, <0: x0 < x1, >0: x0 > x1
927+
* @param[out] obj 0: equal, <0: x0 < x1, >0: x0 > x1
928928
* @retval 0 OK
929929
* @retval -1 Error
930930
*/
@@ -957,8 +957,7 @@ xml_node_same(cxobj *x0,
957957
/* Same object */
958958
y0 = xml_spec(x0);
959959
y1 = xml_spec(x1);
960-
assert(y0 && y1);
961-
if (y0 != y1) /* choice */{
960+
if (y0 && y1 && y0 != y1){ /* choice */
962961
*obj = 1;
963962
goto done;
964963
}
@@ -996,8 +995,28 @@ xml_node_eq(cxobj *x0,
996995
/* Same object */
997996
y0 = xml_spec(x0);
998997
y1 = xml_spec(x1);
999-
assert(y0 && y1);
1000-
if (yang_keyword_get(y0) == Y_LEAF){
998+
if (y0 && y1){
999+
if (yang_keyword_get(y0) == Y_LEAF){
1000+
b0 = xml_body(x0);
1001+
b1 = xml_body(x1);
1002+
if (b0 == NULL && b1 == NULL)
1003+
*eq = 1;
1004+
else if (b0 == NULL || b1 == NULL
1005+
|| strcmp(b0, b1) != 0
1006+
){
1007+
*eq = 0;
1008+
if (value0)
1009+
*value0 = b0;
1010+
if (value1)
1011+
*value1 = b1;
1012+
}
1013+
else
1014+
*eq = 1;
1015+
}
1016+
else
1017+
*eq = 1;
1018+
}
1019+
else{
10011020
b0 = xml_body(x0);
10021021
b1 = xml_body(x1);
10031022
if (b0 == NULL && b1 == NULL)
@@ -1014,8 +1033,6 @@ xml_node_eq(cxobj *x0,
10141033
else
10151034
*eq = 1;
10161035
}
1017-
else
1018-
*eq = 1;
10191036
retval = 0;
10201037
// done:
10211038
return retval;

0 commit comments

Comments
 (0)