Open
Upgrade libyang to 5.4.9 #20
VenlandAdd on Jun 2
Upgrade libyang to 5.4.9 #20
Open
Merged fromVenland/libyangmasterintosrc-openeuler/libyangmaster
Total: 9 files changed+53-537
| @@ -1,65 +0,0 @@ | |||
| 1 | -From a3917d95d516e3de267d3cfa5d4d3715a90e8777 Mon Sep 17 00:00:00 2001 | ||
| 2 | -From: Michal Vasko <mvasko@cesnet.cz> | ||
| 3 | -Date: Mon, 8 Mar 2021 14:08:05 +0100 | ||
| 4 | -Subject: [PATCH] yin parser BUGFIX invalid memory access | ||
| 5 | - | ||
| 6 | -... in case there were some unresolved | ||
| 7 | -extensions. | ||
| 8 | -Fixes #1454 | ||
| 9 | -Fixes #1455 | ||
| 10 | ---- | ||
| 11 | - src/parser_yin.c | 13 +++++++------ | ||
| 12 | - 1 file changed, 7 insertions(+), 6 deletions(-) | ||
| 13 | - | ||
| 14 | -diff --git a/src/parser_yin.c b/src/parser_yin.c | ||
| 15 | -index 275991644..256325415 100644 | ||
| 16 | ---- a/src/parser_yin.c | ||
| 17 | -+++ b/src/parser_yin.c | ||
| 18 | -@@ -4572,7 +4572,7 @@ read_yin_anydata(struct lys_module *module, struct lys_node *parent, struct lyxm | ||
| 19 | - | ||
| 20 | - for (r = 0; r < retval->ext_size; ++r) { | ||
| 21 | - /* set flag, which represent LYEXT_OPT_VALID */ | ||
| 22 | -- if (retval->ext[r]->flags & LYEXT_OPT_VALID) { | ||
| 23 | -+ if (retval->ext[r] && (retval->ext[r]->flags & LYEXT_OPT_VALID)) { | ||
| 24 | - retval->flags |= LYS_VALID_EXT; | ||
| 25 | - break; | ||
| 26 | - } | ||
| 27 | -@@ -4794,7 +4794,7 @@ read_yin_leaf(struct lys_module *module, struct lys_node *parent, struct lyxml_e | ||
| 28 | - | ||
| 29 | - for (r = 0; r < retval->ext_size; ++r) { | ||
| 30 | - /* set flag, which represent LYEXT_OPT_VALID */ | ||
| 31 | -- if (retval->ext[r]->flags & LYEXT_OPT_VALID) { | ||
| 32 | -+ if (retval->ext[r] && (retval->ext[r]->flags & LYEXT_OPT_VALID)) { | ||
| 33 | - retval->flags |= LYS_VALID_EXT; | ||
| 34 | - break; | ||
| 35 | - } | ||
| 36 | -@@ -5108,7 +5108,7 @@ read_yin_leaflist(struct lys_module *module, struct lys_node *parent, struct lyx | ||
| 37 | - | ||
| 38 | - for (r = 0; r < retval->ext_size; ++r) { | ||
| 39 | - /* set flag, which represent LYEXT_OPT_VALID */ | ||
| 40 | -- if (retval->ext[r]->flags & LYEXT_OPT_VALID) { | ||
| 41 | -+ if (retval->ext[r] && (retval->ext[r]->flags & LYEXT_OPT_VALID)) { | ||
| 42 | - retval->flags |= LYS_VALID_EXT; | ||
| 43 | - break; | ||
| 44 | - } | ||
| 45 | -@@ -5477,7 +5477,7 @@ read_yin_list(struct lys_module *module, struct lys_node *parent, struct lyxml_e | ||
| 46 | - | ||
| 47 | - for (r = 0; r < retval->ext_size; ++r) { | ||
| 48 | - /* set flag, which represent LYEXT_OPT_VALID */ | ||
| 49 | -- if (retval->ext[r]->flags & LYEXT_OPT_VALID) { | ||
| 50 | -+ if (retval->ext[r] && (retval->ext[r]->flags & LYEXT_OPT_VALID)) { | ||
| 51 | - retval->flags |= LYS_VALID_EXT; | ||
| 52 | - if (retval->ext[r]->flags & LYEXT_OPT_VALID_SUBTREE) { | ||
| 53 | - retval->flags |= LYS_VALID_EXT_SUBTREE; | ||
| 54 | -@@ -5701,8 +5701,9 @@ read_yin_container(struct lys_module *module, struct lys_node *parent, struct ly | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - for (r = 0; r < retval->ext_size; ++r) { | ||
| 58 | -- /* set flag, which represent LYEXT_OPT_VALID */ | ||
| 59 | -- if (retval->ext[r]->flags & LYEXT_OPT_VALID) { | ||
| 60 | -+ /* extension instance may not yet be resolved */ | ||
| 61 | -+ if (retval->ext[r] && (retval->ext[r]->flags & LYEXT_OPT_VALID)) { | ||
| 62 | -+ /* set flag, which represent LYEXT_OPT_VALID */ | ||
| 63 | - retval->flags |= LYS_VALID_EXT; | ||
| 64 | - if (retval->ext[r]->flags & LYEXT_OPT_VALID_SUBTREE) { | ||
| 65 | - retval->flags |= LYS_VALID_EXT_SUBTREE; | ||
| @@ -1,69 +0,0 @@ | |||
| 1 | -From 298b30ea4ebee137226acf9bb38678bd82704582 Mon Sep 17 00:00:00 2001 | ||
| 2 | -From: Michal Vasko <mvasko@cesnet.cz> | ||
| 3 | -Date: Mon, 8 Mar 2021 14:32:58 +0100 | ||
| 4 | -Subject: [PATCH] common FEATURE add a hard limit for recursion | ||
| 5 | - | ||
| 6 | -Fixes #1453 | ||
| 7 | ---- | ||
| 8 | - src/common.h.in | 3 +++ | ||
| 9 | - src/xml.c | 12 +++++++++--- | ||
| 10 | - 2 files changed, 12 insertions(+), 3 deletions(-) | ||
| 11 | - | ||
| 12 | -diff --git a/src/common.h.in b/src/common.h.in | ||
| 13 | -index a5bf2b038..624beba9f 100644 | ||
| 14 | ---- a/src/common.h.in | ||
| 15 | -+++ b/src/common.h.in | ||
| 16 | -@@ -53,6 +53,9 @@ | ||
| 17 | - /* how many bytes add when enlarging buffers */ | ||
| 18 | - #define LY_BUF_STEP 128 | ||
| 19 | - | ||
| 20 | -+/* hard limit on recursion for cases with theoretical unlimited recursion */ | ||
| 21 | -+#define LY_RECURSION_LIMIT 10000 | ||
| 22 | -+ | ||
| 23 | - /* internal logging options */ | ||
| 24 | - enum int_log_opts { | ||
| 25 | - ILO_LOG = 0, /* log normally */ | ||
| 26 | -diff --git a/src/xml.c b/src/xml.c | ||
| 27 | -index 1bc4fdfa5..7e4760976 100644 | ||
| 28 | ---- a/src/xml.c | ||
| 29 | -+++ b/src/xml.c | ||
| 30 | -@@ -943,7 +943,8 @@ parse_attr(struct ly_ctx *ctx, const char *data, unsigned int *len, struct lyxml | ||
| 31 | - | ||
| 32 | - /* logs directly */ | ||
| 33 | - struct lyxml_elem * | ||
| 34 | --lyxml_parse_elem(struct ly_ctx *ctx, const char *data, unsigned int *len, struct lyxml_elem *parent, int options) | ||
| 35 | -+lyxml_parse_elem(struct ly_ctx *ctx, const char *data, unsigned int *len, struct lyxml_elem *parent, int options, | ||
| 36 | -+ int bt_count) | ||
| 37 | - { | ||
| 38 | - const char *c = data, *start, *e; | ||
| 39 | - const char *lws; /* leading white space for handling mixed content */ | ||
| 40 | -@@ -958,6 +959,11 @@ lyxml_parse_elem(struct ly_ctx *ctx, const char *data, unsigned int *len, struct | ||
| 41 | - | ||
| 42 | - *len = 0; | ||
| 43 | - | ||
| 44 | -+ if (bt_count > LY_RECURSION_LIMIT) { | ||
| 45 | -+ LOGVAL(ctx, LYE_XML_INVAL, LY_VLOG_NONE, NULL, "Recursion limit %d reached", LY_RECURSION_LIMIT); | ||
| 46 | -+ return NULL; | ||
| 47 | -+ } | ||
| 48 | -+ | ||
| 49 | - if (*c != '<') { | ||
| 50 | - return NULL; | ||
| 51 | - } | ||
| 52 | -@@ -1141,7 +1147,7 @@ lyxml_parse_elem(struct ly_ctx *ctx, const char *data, unsigned int *len, struct | ||
| 53 | - lyxml_add_child(ctx, elem, child); | ||
| 54 | - elem->flags |= LYXML_ELEM_MIXED; | ||
| 55 | - } | ||
| 56 | -- child = lyxml_parse_elem(ctx, c, &size, elem, options); | ||
| 57 | -+ child = lyxml_parse_elem(ctx, c, &size, elem, options, bt_count + 1); | ||
| 58 | - if (!child) { | ||
| 59 | - goto error; | ||
| 60 | - } | ||
| 61 | -@@ -1295,7 +1301,7 @@ lyxml_parse_mem(struct ly_ctx *ctx, const char *data, int options) | ||
| 62 | - } | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | -- root = lyxml_parse_elem(ctx, c, &len, NULL, options); | ||
| 66 | -+ root = lyxml_parse_elem(ctx, c, &len, NULL, options, 0); | ||
| 67 | - if (!root) { | ||
| 68 | - goto error; | ||
| 69 | - } else if (!first) { | ||
| @@ -1,26 +0,0 @@ | |||
| 1 | -From 59a0bff1a5a2f0a0eac07e4bf94d4aea9dd3708d Mon Sep 17 00:00:00 2001 | ||
| 2 | -From: Michal Vasko <mvasko@cesnet.cz> | ||
| 3 | -Date: Mon, 8 Mar 2021 09:20:30 +0100 | ||
| 4 | -Subject: [PATCH] plugins BUGFIX handle empty revision correctly | ||
| 5 | - | ||
| 6 | -Fixes #1451 | ||
| 7 | ---- | ||
| 8 | - src/plugins.c | 5 ++--- | ||
| 9 | - 1 file changed, 2 insertions(+), 3 deletions(-) | ||
| 10 | - | ||
| 11 | -diff --git a/src/plugins.c b/src/plugins.c | ||
| 12 | -index 7e6fdf358..fa62ce76c 100644 | ||
| 13 | ---- a/src/plugins.c | ||
| 14 | -+++ b/src/plugins.c | ||
| 15 | -@@ -457,9 +457,8 @@ ext_get_plugin(const char *name, const char *module, const char *revision) | ||
| 16 | - assert(module); | ||
| 17 | - | ||
| 18 | - for (u = 0; u < ext_plugins_count; u++) { | ||
| 19 | -- if (!strcmp(name, ext_plugins[u].name) && | ||
| 20 | -- !strcmp(module, ext_plugins[u].module) && | ||
| 21 | -- (!ext_plugins[u].revision || !strcmp(revision, ext_plugins[u].revision))) { | ||
| 22 | -+ if (!strcmp(name, ext_plugins[u].name) && !strcmp(module, ext_plugins[u].module) && | ||
| 23 | -+ ((!revision && !ext_plugins[u].revision) || (revision && !strcmp(revision, ext_plugins[u].revision)))) { | ||
| 24 | - /* we have the match */ | ||
| 25 | - return ext_plugins[u].plugin; | ||
| 26 | - } | ||
| @@ -1,263 +0,0 @@ | |||
| 1 | -From 5ce30801f9ccc372bbe9b7c98bb5324b15fb010a Mon Sep 17 00:00:00 2001 | ||
| 2 | -From: Michal Vasko <mvasko@cesnet.cz> | ||
| 3 | -Date: Mon, 8 Mar 2021 09:34:04 +0100 | ||
| 4 | -Subject: [PATCH] schema tree BUGFIX freeing nodes with no module set | ||
| 5 | - | ||
| 6 | -Context must be passed explicitly for these cases. | ||
| 7 | -Fixes #1452 | ||
| 8 | ---- | ||
| 9 | - src/parser_yin.c | 24 ++++++++++++------------ | ||
| 10 | - src/resolve.c | 2 +- | ||
| 11 | - src/tree_internal.h | 4 +++- | ||
| 12 | - src/tree_schema.c | 27 +++++++++++---------------- | ||
| 13 | - 4 files changed, 27 insertions(+), 30 deletions(-) | ||
| 14 | - | ||
| 15 | -diff --git a/src/parser_yin.c b/src/parser_yin.c | ||
| 16 | -index d545a6d26..275991644 100644 | ||
| 17 | ---- a/src/parser_yin.c | ||
| 18 | -+++ b/src/parser_yin.c | ||
| 19 | -@@ -4213,7 +4213,7 @@ read_yin_case(struct lys_module *module, struct lys_node *parent, struct lyxml_e | ||
| 20 | - while (root.child) { | ||
| 21 | - lyxml_free(ctx, root.child); | ||
| 22 | - } | ||
| 23 | -- lys_node_free(retval, NULL, 0); | ||
| 24 | -+ lys_node_free(ctx, retval, NULL, 0); | ||
| 25 | - | ||
| 26 | - return NULL; | ||
| 27 | - } | ||
| 28 | -@@ -4420,7 +4420,7 @@ read_yin_choice(struct lys_module *module, struct lys_node *parent, struct lyxml | ||
| 29 | - | ||
| 30 | - error: | ||
| 31 | - lyxml_free(ctx, dflt); | ||
| 32 | -- lys_node_free(retval, NULL, 0); | ||
| 33 | -+ lys_node_free(ctx, retval, NULL, 0); | ||
| 34 | - return NULL; | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | -@@ -4581,7 +4581,7 @@ read_yin_anydata(struct lys_module *module, struct lys_node *parent, struct lyxm | ||
| 38 | - return retval; | ||
| 39 | - | ||
| 40 | - error: | ||
| 41 | -- lys_node_free(retval, NULL, 0); | ||
| 42 | -+ lys_node_free(ctx, retval, NULL, 0); | ||
| 43 | - return NULL; | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | -@@ -4803,7 +4803,7 @@ read_yin_leaf(struct lys_module *module, struct lys_node *parent, struct lyxml_e | ||
| 47 | - return retval; | ||
| 48 | - | ||
| 49 | - error: | ||
| 50 | -- lys_node_free(retval, NULL, 0); | ||
| 51 | -+ lys_node_free(ctx, retval, NULL, 0); | ||
| 52 | - return NULL; | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | -@@ -5117,7 +5117,7 @@ read_yin_leaflist(struct lys_module *module, struct lys_node *parent, struct lyx | ||
| 56 | - return retval; | ||
| 57 | - | ||
| 58 | - error: | ||
| 59 | -- lys_node_free(retval, NULL, 0); | ||
| 60 | -+ lys_node_free(ctx, retval, NULL, 0); | ||
| 61 | - return NULL; | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | -@@ -5490,7 +5490,7 @@ read_yin_list(struct lys_module *module, struct lys_node *parent, struct lyxml_e | ||
| 65 | - | ||
| 66 | - error: | ||
| 67 | - | ||
| 68 | -- lys_node_free(retval, NULL, 0); | ||
| 69 | -+ lys_node_free(ctx, retval, NULL, 0); | ||
| 70 | - while (root.child) { | ||
| 71 | - lyxml_free(ctx, root.child); | ||
| 72 | - } | ||
| 73 | -@@ -5714,7 +5714,7 @@ read_yin_container(struct lys_module *module, struct lys_node *parent, struct ly | ||
| 74 | - return retval; | ||
| 75 | - | ||
| 76 | - error: | ||
| 77 | -- lys_node_free(retval, NULL, 0); | ||
| 78 | -+ lys_node_free(ctx, retval, NULL, 0); | ||
| 79 | - while (root.child) { | ||
| 80 | - lyxml_free(ctx, root.child); | ||
| 81 | - } | ||
| 82 | -@@ -5859,7 +5859,7 @@ read_yin_grouping(struct lys_module *module, struct lys_node *parent, struct lyx | ||
| 83 | - return retval; | ||
| 84 | - | ||
| 85 | - error: | ||
| 86 | -- lys_node_free(retval, NULL, 0); | ||
| 87 | -+ lys_node_free(ctx, retval, NULL, 0); | ||
| 88 | - while (root.child) { | ||
| 89 | - lyxml_free(ctx, root.child); | ||
| 90 | - } | ||
| 91 | -@@ -6035,7 +6035,7 @@ read_yin_input_output(struct lys_module *module, struct lys_node *parent, struct | ||
| 92 | - return retval; | ||
| 93 | - | ||
| 94 | - error: | ||
| 95 | -- lys_node_free(retval, NULL, 0); | ||
| 96 | -+ lys_node_free(ctx, retval, NULL, 0); | ||
| 97 | - while (root.child) { | ||
| 98 | - lyxml_free(ctx, root.child); | ||
| 99 | - } | ||
| 100 | -@@ -6216,7 +6216,7 @@ read_yin_notif(struct lys_module *module, struct lys_node *parent, struct lyxml_ | ||
| 101 | - return retval; | ||
| 102 | - | ||
| 103 | - error: | ||
| 104 | -- lys_node_free(retval, NULL, 0); | ||
| 105 | -+ lys_node_free(ctx, retval, NULL, 0); | ||
| 106 | - while (root.child) { | ||
| 107 | - lyxml_free(ctx, root.child); | ||
| 108 | - } | ||
| 109 | -@@ -6368,7 +6368,7 @@ read_yin_rpc_action(struct lys_module *module, struct lys_node *parent, struct l | ||
| 110 | - return retval; | ||
| 111 | - | ||
| 112 | - error: | ||
| 113 | -- lys_node_free(retval, NULL, 0); | ||
| 114 | -+ lys_node_free(ctx, retval, NULL, 0); | ||
| 115 | - while (root.child) { | ||
| 116 | - lyxml_free(ctx, root.child); | ||
| 117 | - } | ||
| 118 | -@@ -6522,7 +6522,7 @@ read_yin_uses(struct lys_module *module, struct lys_node *parent, struct lyxml_e | ||
| 119 | - return retval; | ||
| 120 | - | ||
| 121 | - error: | ||
| 122 | -- lys_node_free(retval, NULL, 0); | ||
| 123 | -+ lys_node_free(ctx, retval, NULL, 0); | ||
| 124 | - return NULL; | ||
| 125 | - } | ||
| 126 | - | ||
| 127 | -diff --git a/src/resolve.c b/src/resolve.c | ||
| 128 | -index 21293ebc2..29862187f 100644 | ||
| 129 | ---- a/src/resolve.c | ||
| 130 | -+++ b/src/resolve.c | ||
| 131 | -@@ -5654,7 +5654,7 @@ resolve_uses(struct lys_node_uses *uses, struct unres_schema *unres) | ||
| 132 | - | ||
| 133 | - fail: | ||
| 134 | - LY_TREE_FOR_SAFE(uses->child, next, iter) { | ||
| 135 | -- lys_node_free(iter, NULL, 0); | ||
| 136 | -+ lys_node_free(ctx, iter, NULL, 0); | ||
| 137 | - } | ||
| 138 | - free(refine_nodes); | ||
| 139 | - return -1; | ||
| 140 | -diff --git a/src/tree_internal.h b/src/tree_internal.h | ||
| 141 | -index 497c62c4d..36e94f5c5 100644 | ||
| 142 | ---- a/src/tree_internal.h | ||
| 143 | -+++ b/src/tree_internal.h | ||
| 144 | -@@ -368,12 +368,14 @@ void lys_node_unlink(struct lys_node *node); | ||
| 145 | - /** | ||
| 146 | - * @brief Free the schema node structure, includes unlinking it from the tree | ||
| 147 | - * | ||
| 148 | -+ * @param[in] ctx libang context to use, @p node may not have it filled (in groupings, for example). | ||
| 149 | - * @param[in] node Schema tree node to free. Do not use the pointer after calling this function. | ||
| 150 | - * @param[in] private_destructor Optional destructor function for private objects assigned | ||
| 151 | - * to the nodes via lys_set_private(). If NULL, the private objects are not freed by libyang. | ||
| 152 | - * @param[in] shallow Whether to do a shallow free only (on a shallow copy of a node). | ||
| 153 | - */ | ||
| 154 | --void lys_node_free(struct lys_node *node, void (*private_destructor)(const struct lys_node *node, void *priv), int shallow); | ||
| 155 | -+void lys_node_free(struct ly_ctx *ctx, struct lys_node *node, | ||
| 156 | -+ void (*private_destructor)(const struct lys_node *node, void *priv), int shallow); | ||
| 157 | - | ||
| 158 | - /** | ||
| 159 | - * @brief Free (and unlink it from the context) the specified schema. | ||
| 160 | -diff --git a/src/tree_schema.c b/src/tree_schema.c | ||
| 161 | -index 43b19039f..fb4c85f3f 100644 | ||
| 162 | ---- a/src/tree_schema.c | ||
| 163 | -+++ b/src/tree_schema.c | ||
| 164 | -@@ -942,7 +942,7 @@ lys_node_addchild(struct lys_node *parent, struct lys_module *module, struct lys | ||
| 165 | - iter->next = NULL; | ||
| 166 | - iter->prev = iter; | ||
| 167 | - iter->parent = NULL; | ||
| 168 | -- lys_node_free(iter, NULL, 0); | ||
| 169 | -+ lys_node_free(ctx, iter, NULL, 0); | ||
| 170 | - } else { | ||
| 171 | - if (shortcase) { | ||
| 172 | - /* create the implicit case to allow it to serve as a target of the augments, | ||
| 173 | -@@ -2464,7 +2464,7 @@ lys_augment_free(struct ly_ctx *ctx, struct lys_node_augment *aug, | ||
| 174 | - /* children from a resolved augment are freed under the target node */ | ||
| 175 | - if (!aug->target || (aug->flags & LYS_NOTAPPLIED)) { | ||
| 176 | - LY_TREE_FOR_SAFE(aug->child, next, sub) { | ||
| 177 | -- lys_node_free(sub, private_destructor, 0); | ||
| 178 | -+ lys_node_free(ctx, sub, private_destructor, 0); | ||
| 179 | - } | ||
| 180 | - } | ||
| 181 | - | ||
| 182 | -@@ -2722,11 +2722,11 @@ lys_deviation_free(struct lys_module *module, struct lys_deviation *dev, | ||
| 183 | - | ||
| 184 | - LY_TREE_DFS_END(dev->orig_node, next, elem); | ||
| 185 | - } | ||
| 186 | -- lys_node_free(dev->orig_node, NULL, 0); | ||
| 187 | -+ lys_node_free(ctx, dev->orig_node, NULL, 0); | ||
| 188 | - } else { | ||
| 189 | - /* it's just a shallow copy, freeing one node */ | ||
| 190 | - dev->orig_node->module = module; | ||
| 191 | -- lys_node_free(dev->orig_node, NULL, 1); | ||
| 192 | -+ lys_node_free(ctx, dev->orig_node, NULL, 1); | ||
| 193 | - } | ||
| 194 | - } | ||
| 195 | - | ||
| 196 | -@@ -2798,20 +2798,15 @@ lys_uses_free(struct ly_ctx *ctx, struct lys_node_uses *uses, | ||
| 197 | - } | ||
| 198 | - | ||
| 199 | - void | ||
| 200 | --lys_node_free(struct lys_node *node, void (*private_destructor)(const struct lys_node *node, void *priv), int shallow) | ||
| 201 | -+lys_node_free(struct ly_ctx *ctx, struct lys_node *node, | ||
| 202 | -+ void (*private_destructor)(const struct lys_node *node, void *priv), int shallow) | ||
| 203 | - { | ||
| 204 | -- struct ly_ctx *ctx; | ||
| 205 | - struct lys_node *sub, *next; | ||
| 206 | - | ||
| 207 | - if (!node) { | ||
| 208 | - return; | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | -- assert(node->module); | ||
| 212 | -- assert(node->module->ctx); | ||
| 213 | -- | ||
| 214 | -- ctx = node->module->ctx; | ||
| 215 | -- | ||
| 216 | - /* remove private object */ | ||
| 217 | - if (node->priv && private_destructor) { | ||
| 218 | - private_destructor(node, node->priv); | ||
| 219 | -@@ -2827,7 +2822,7 @@ lys_node_free(struct lys_node *node, void (*private_destructor)(const struct lys | ||
| 220 | - | ||
| 221 | - if (!shallow && !(node->nodetype & (LYS_LEAF | LYS_LEAFLIST))) { | ||
| 222 | - LY_TREE_FOR_SAFE(node->child, next, sub) { | ||
| 223 | -- lys_node_free(sub, private_destructor, 0); | ||
| 224 | -+ lys_node_free(ctx, sub, private_destructor, 0); | ||
| 225 | - } | ||
| 226 | - } | ||
| 227 | - | ||
| 228 | -@@ -2942,7 +2937,7 @@ module_free_common(struct lys_module *module, void (*private_destructor)(const s | ||
| 229 | - * are placed in the main module altogether */ | ||
| 230 | - if (!module->type) { | ||
| 231 | - LY_TREE_FOR_SAFE(module->data, next, iter) { | ||
| 232 | -- lys_node_free(iter, private_destructor, 0); | ||
| 233 | -+ lys_node_free(ctx, iter, private_destructor, 0); | ||
| 234 | - } | ||
| 235 | - } | ||
| 236 | - | ||
| 237 | -@@ -3507,7 +3502,7 @@ lys_node_dup_recursion(struct lys_module *module, struct lys_node *parent, const | ||
| 238 | - return retval; | ||
| 239 | - | ||
| 240 | - error: | ||
| 241 | -- lys_node_free(retval, NULL, 0); | ||
| 242 | -+ lys_node_free(ctx, retval, NULL, 0); | ||
| 243 | - return NULL; | ||
| 244 | - } | ||
| 245 | - | ||
| 246 | -@@ -5149,7 +5144,7 @@ lys_submodule_module_data_free(struct lys_submodule *submodule) | ||
| 247 | - /* remove parsed data */ | ||
| 248 | - LY_TREE_FOR_SAFE(submodule->belongsto->data, next, elem) { | ||
| 249 | - if (elem->module == (struct lys_module *)submodule) { | ||
| 250 | -- lys_node_free(elem, NULL, 0); | ||
| 251 | -+ lys_node_free(submodule->ctx, elem, NULL, 0); | ||
| 252 | - } | ||
| 253 | - } | ||
| 254 | - } | ||
| 255 | -@@ -5546,7 +5541,7 @@ lys_extension_instances_free(struct ly_ctx *ctx, struct lys_ext_instance **e, un | ||
| 256 | - case LY_STMT_USES: | ||
| 257 | - pp = (void**)&((struct lys_ext_instance_complex *)e[i])->content[substmt[j].offset]; | ||
| 258 | - LY_TREE_FOR_SAFE((struct lys_node *)(*pp), snext, siter) { | ||
| 259 | -- lys_node_free(siter, NULL, 0); | ||
| 260 | -+ lys_node_free(ctx, siter, NULL, 0); | ||
| 261 | - } | ||
| 262 | - *pp = NULL; | ||
| 263 | - break; | ||
| @@ -1,19 +0,0 @@ | |||
| 1 | -commit 66db639f2c6c1b9dda8cf18e2a212f160b268a3b | ||
| 2 | -Author: Tomas Korbar <tkorbar@redhat.com> | ||
| 3 | -Date: Thu Jul 23 09:35:56 2020 +0200 | ||
| 4 | - | ||
| 5 | - Search for libyang.h in build directory | ||
| 6 | - | ||
| 7 | -diff --git a/Doxyfile.in b/Doxyfile.in | ||
| 8 | -index 2534da3..272248e 100644 | ||
| 9 | ---- a/Doxyfile.in | ||
| 10 | -+++ b/Doxyfile.in | ||
| 11 | -@@ -781,7 +781,7 @@ WARN_LOGFILE = | ||
| 12 | - # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING | ||
| 13 | - # Note: If this tag is empty the current directory is searched. | ||
| 14 | - | ||
| 15 | --INPUT = @CMAKE_BINARY_DIR@/src/libyang.h \ | ||
| 16 | -+INPUT = ./build/src/libyang.h \ | ||
| 17 | - ./src/tree_data.h \ | ||
| 18 | - ./src/tree_schema.h \ | ||
| 19 | - ./src/extensions.h \ | ||
Binary files do not support preview
| @@ -1,108 +1,75 @@ | |||
| 1 | Name: libyang | 1 | Name: libyang |
| 2 | -Version: 1.0.184 | 2 | +Version: 5.8.6 |
| 3 | -Release: 6 | 3 | +Release: 1 |
| 4 | Summary: YANG data modeling language library | 4 | Summary: YANG data modeling language library |
| 5 | Url: https://github.com/CESNET/libyang | 5 | Url: https://github.com/CESNET/libyang |
| 6 | -Source: %{url}/archive/%{name}-%{version}.tar.gz | 6 | +Source: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz |
| 7 | License: BSD | 7 | License: BSD |
| 8 | 8 | ||
| 9 | -Patch0: libyang-1.0.184-doc.patch | ||
| 10 | -Patch1: CVE-2021-28903.patch | ||
| 11 | -Patch2: CVE-2021-28905.patch | ||
| 12 | -Patch3: CVE-2021-28904.patch | ||
| 13 | -Patch4: CVE-2021-28902-CVE-2021-28906.patch | ||
| 14 | - | ||
| 15 | -Requires: pcre | ||
| 16 | BuildRequires: cmake | 9 | BuildRequires: cmake |
| 17 | BuildRequires: doxygen | 10 | BuildRequires: doxygen |
| 18 | -BuildRequires: pcre-devel | ||
| 19 | BuildRequires: gcc | 11 | BuildRequires: gcc |
| 20 | BuildRequires: gcc-c++ | 12 | BuildRequires: gcc-c++ |
| 21 | -BuildRequires: swig >= 3.0.12 | 13 | +BuildRequires: make |
| 22 | BuildRequires: libcmocka-devel | 14 | BuildRequires: libcmocka-devel |
| 23 | -BuildRequires: python3-devel | 15 | +BuildRequires: pcre2-devel |
| 24 | -BuildRequires: flex | ||
| 25 | -BuildRequires: bison | ||
| 26 | -BuildRequires: graphviz | ||
| 27 | - | ||
| 28 | -%package devel | ||
| 29 | -Summary: Development files for libyang | ||
| 30 | -Requires: %{name}%{?_isa} = %{version}-%{release} | ||
| 31 | -Requires: pcre-devel | ||
| 32 | - | ||
| 33 | -%package devel-doc | ||
| 34 | -Summary: Documentation of libyang API | ||
| 35 | -Requires: %{name} = %{version}-%{release} | ||
| 36 | -BuildArch: noarch | ||
| 37 | - | ||
| 38 | -%package -n libyang-cpp | ||
| 39 | -Summary: C++ bindings for libyang | ||
| 40 | -Requires: %{name}%{?_isa} = %{version}-%{release} | ||
| 41 | - | ||
| 42 | -%package -n libyang-cpp-devel | ||
| 43 | -Summary: Development files for libyang-cpp | ||
| 44 | -Requires: libyang-cpp%{?_isa} = %{version}-%{release} | ||
| 45 | -Requires: pcre-devel | ||
| 46 | - | ||
| 47 | -%package -n python3-yang | ||
| 48 | -Summary: Python3 bindings for libyang | ||
| 49 | -Requires: libyang-cpp%{?_isa} = %{version}-%{release} | ||
| 50 | -%{?python_provide:%python_provide python3-libyang} | ||
| 51 | - | ||
| 52 | -%description -n libyang-cpp | ||
| 53 | -Bindings of libyang library to C++ language. | ||
| 54 | - | ||
| 55 | -%description -n libyang-cpp-devel | ||
| 56 | -Headers of bindings to c++ language. | ||
| 57 | - | ||
| 58 | -%description -n python3-yang | ||
| 59 | -Bindings of libyang library to python language. | ||
| 60 | - | ||
| 61 | -%description devel | ||
| 62 | -Headers of libyang library. | ||
| 63 | - | ||
| 64 | -%description devel-doc | ||
| 65 | -Documentation of libyang API. | ||
| 66 | 16 | ||
| 67 | %description | 17 | %description |
| 68 | Libyang is YANG data modeling language parser and toolkit | 18 | Libyang is YANG data modeling language parser and toolkit |
| 69 | written (and providing API) in C. | 19 | written (and providing API) in C. |
| 70 | 20 | ||
| 21 | +%package modules | ||
| 22 | +Summary: YANG modules for libyang | ||
| 23 | + | ||
| 24 | +%description modules | ||
| 25 | +YANG modules for libyang. | ||
| 26 | + | ||
| 27 | +%package devel | ||
| 28 | +Summary: Development files for libyang | ||
| 29 | +Requires: %{name}%{?_isa} = %{version}-%{release} | ||
| 30 | +Requires: pcre2-devel | ||
| 31 | + | ||
| 32 | +%description devel | ||
| 33 | +Headers of libyang library. | ||
| 34 | + | ||
| 35 | +%package tools | ||
| 36 | +Summary: YANG validator tools | ||
| 37 | +Requires: %{name}%{?_isa} = %{version}-%{release} | ||
| 38 | + | ||
| 39 | +%description tools | ||
| 40 | +YANG validator tools. | ||
| 41 | + | ||
| 71 | %prep | 42 | %prep |
| 72 | -%autosetup -n %{name}-%{version} -p1 | 43 | +%autosetup -p1 |
| 73 | 44 | ||
| 74 | -mkdir build && cd build | 45 | +%build |
| 75 | -cmake \ | 46 | +# Limit parallel jobs to avoid OOM on memory-constrained build hosts |
| 76 | - -DCMAKE_INSTALL_PREFIX:PATH=/usr \ | 47 | +%cmake -DCMAKE_BUILD_TYPE=RELWITHDEBINFO |
| 77 | - -DCMAKE_BUILD_TYPE:String="Package" \ | 48 | +%cmake_build -j2 |
| 78 | - -DENABLE_LYD_PRIV=ON \ | ||
| 79 | - -DGEN_JAVA_BINDINGS=OFF \ | ||
| 80 | - -DGEN_JAVASCRIPT_BINDINGS=OFF \ | ||
| 81 | - -DGEN_LANGUAGE_BINDINGS=ON \ | ||
| 82 | - -DENABLE_VALGRIND_TESTS=OFF .. | ||
| 83 | - | ||
| 84 | -make | ||
| 85 | -make doc | ||
| 86 | 49 | ||
| 87 | %check | 50 | %check |
| 88 | -ctest --output-on-failure -V %{?_smp_mflags} | 51 | +# Limit parallel tests to avoid memory issues |
| 52 | +%ctest --output-on-failure -V -j2 | ||
| 89 | 53 | ||
| 90 | %install | 54 | %install |
| 91 | -cd build | 55 | +%cmake_install |
| 92 | -%{__make} install DESTDIR=%{?buildroot} INSTALL="%{__install} -p" | ||
| 93 | -cd ../ | ||
| 94 | -mkdir -m0755 -p %{buildroot}/%{_docdir}/libyang | ||
| 95 | -cp -r doc/html %{buildroot}/%{_docdir}/libyang/html | ||
| 96 | 56 | ||
| 97 | %files | 57 | %files |
| 98 | %license LICENSE | 58 | %license LICENSE |
| 59 | +%{_libdir}/libyang.so.5 | ||
| 60 | +%{_libdir}/libyang.so.5.* | ||
| 61 | + | ||
| 62 | +%files modules | ||
| 63 | +%{_datadir}/yang/modules/libyang/*.yang | ||
| 64 | +%dir %{_datadir}/yang/ | ||
| 65 | +%dir %{_datadir}/yang/modules/ | ||
| 66 | +%dir %{_datadir}/yang/modules/libyang/ | ||
| 67 | + | ||
| 68 | +%files tools | ||
| 99 | %{_bindir}/yanglint | 69 | %{_bindir}/yanglint |
| 100 | %{_bindir}/yangre | 70 | %{_bindir}/yangre |
| 101 | %{_datadir}/man/man1/yanglint.1.gz | 71 | %{_datadir}/man/man1/yanglint.1.gz |
| 102 | %{_datadir}/man/man1/yangre.1.gz | 72 | %{_datadir}/man/man1/yangre.1.gz |
| 103 | -%{_libdir}/libyang.so.1 | ||
| 104 | -%{_libdir}/libyang.so.1.* | ||
| 105 | -%{_libdir}/libyang1 | ||
| 106 | 73 | ||
| 107 | %files devel | 74 | %files devel |
| 108 | %{_libdir}/libyang.so | 75 | %{_libdir}/libyang.so |
| @@ -110,25 +77,16 @@ cp -r doc/html %{buildroot}/%{_docdir}/libyang/html | |||
| 110 | %{_includedir}/libyang/*.h | 77 | %{_includedir}/libyang/*.h |
| 111 | %dir %{_includedir}/libyang/ | 78 | %dir %{_includedir}/libyang/ |
| 112 | 79 | ||
| 113 | -%files devel-doc | ||
| 114 | -%{_docdir}/libyang | ||
| 115 | - | ||
| 116 | -%files -n libyang-cpp | ||
| 117 | -%{_libdir}/libyang-cpp.so.1 | ||
| 118 | -%{_libdir}/libyang-cpp.so.1.* | ||
| 119 | - | ||
| 120 | -%files -n libyang-cpp-devel | ||
| 121 | -%{_libdir}/libyang-cpp.so | ||
| 122 | -%{_includedir}/libyang/*.hpp | ||
| 123 | -%{_libdir}/pkgconfig/libyang-cpp.pc | ||
| 124 | -%dir %{_includedir}/libyang/ | ||
| 125 | - | ||
| 126 | -%files -n python3-yang | ||
| 127 | -%{python3_sitearch}/yang.py | ||
| 128 | -%{python3_sitearch}/_yang.so | ||
| 129 | -%{python3_sitearch}/__pycache__/yang* | ||
| 130 | - | ||
| 131 | %changelog | 80 | %changelog |
| 81 | +* Tue Jun 23 2026 liweigang <liweiganga@gmail.com> - 5.8.6-1 | ||
| 82 | +- update to 5.8.6 (required by sysrepo >= 5.0) | ||
| 83 | +- drop old CVE patches (fixed upstream) | ||
| 84 | +- switch from pcre to pcre2 | ||
| 85 | +- remove C++/Python/SWIG bindings (dropped since v2) | ||
| 86 | +- restructure subpackages: add modules, tools; remove cpp, python | ||
| 87 | +- use %%cmake/%%cmake_build/%%cmake_install macros | ||
| 88 | +- modernize spec based on upstream distro/pkg/rpm/libyang.spec | ||
| 89 | + | ||
| 132 | * Tue Mar 07 2023 zhouwenpei <zhouwenpei@h-partners.com> - 1.0.184-6 | 90 | * Tue Mar 07 2023 zhouwenpei <zhouwenpei@h-partners.com> - 1.0.184-6 |
| 133 | - remove debug_package %{nil} to strip files and provide debug packages | 91 | - remove debug_package %{nil} to strip files and provide debug packages |
| 134 | 92 | ||