From ec203379d11156a3aa99d424b7f690107244446a Mon Sep 17 00:00:00 2001 From: SESA741771 Date: Wed, 23 Apr 2025 13:24:05 +0200 Subject: [PATCH 1/6] src/parser_yin.c: coverity fix - missing varargs init or cleanup --- src/parser_yin.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/parser_yin.c b/src/parser_yin.c index a280423d8..fb10e1784 100644 --- a/src/parser_yin.c +++ b/src/parser_yin.c @@ -396,6 +396,7 @@ subelems_allocator(struct lysp_yin_ctx *ctx, size_t count, struct lysp_node *par return LY_SUCCESS; mem_err: + va_end(ap); subelems_deallocator(count, *result); LOGMEM(ctx->xmlctx->ctx); return LY_EMEM; From 3842eee018fafcf6daafcee1104562a86ec39bc2 Mon Sep 17 00:00:00 2001 From: SESA741771 Date: Wed, 23 Apr 2025 13:26:09 +0200 Subject: [PATCH 2/6] src/schema_compile_node.c: coverity fix - overflowed constant --- src/schema_compile_node.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c index 9c230cd73..a7e716888 100644 --- a/src/schema_compile_node.c +++ b/src/schema_compile_node.c @@ -1229,7 +1229,9 @@ lys_compile_pattern_chblocks_xmlschema2perl(const struct ly_ctx *ctx, const char ++idx; } if ((perl_regex[idx2] == ']') && (!idx2 || (perl_regex[idx2 - 1] != '\\'))) { - --idx; + if (idx > 0) { + --idx; + } } } if (idx) { From 734583739aca8d73655158ef4b20e3362f8de8d9 Mon Sep 17 00:00:00 2001 From: SESA741771 Date: Wed, 23 Apr 2025 13:27:04 +0200 Subject: [PATCH 3/6] src/xpath.c: coverity fix - overflowed constant --- src/xpath.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/xpath.c b/src/xpath.c index 5429eca74..7fb3c9260 100644 --- a/src/xpath.c +++ b/src/xpath.c @@ -8250,7 +8250,9 @@ eval_name_test_with_predicate(const struct lyxp_expr *exp, uint32_t *tok_idx, en if (set->used) { i = set->used; do { - --i; + if (i > 0) { + --i; + } if (set->val.scnodes[i].in_ctx > LYXP_SET_SCNODE_ATOM_NODE) { found = 1; break; From aad24f5d52c2c75bd47713ac1e9b5905c15dded0 Mon Sep 17 00:00:00 2001 From: SESA741771 Date: Wed, 23 Apr 2025 13:42:16 +0200 Subject: [PATCH 4/6] src/ly_common.c: coverity fix - missing varargs init or cleanup --- src/ly_common.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ly_common.c b/src/ly_common.c index 449c862f9..ac62677ef 100644 --- a/src/ly_common.c +++ b/src/ly_common.c @@ -325,6 +325,7 @@ ly_utf8_and_equal(const char *input, int bytes, ...) /* compare each byte */ if (((uint8_t)input[i] & and) != (uint8_t)byte) { + va_end(ap); return 0; } } @@ -355,8 +356,10 @@ ly_utf8_less(const char *input, int bytes, ...) /* compare until bytes differ */ if ((uint8_t)input[i] > (uint8_t)byte) { + va_end(ap); return 0; } else if ((uint8_t)input[i] < (uint8_t)byte) { + va_end(ap); return 1; } } @@ -388,8 +391,10 @@ ly_utf8_greater(const char *input, int bytes, ...) /* compare until bytes differ */ if ((uint8_t)input[i] > (uint8_t)byte) { + va_end(ap); return 1; } else if ((uint8_t)input[i] < (uint8_t)byte) { + va_end(ap); return 0; } } From b64958d54bd994377b1556b5aed4e0e587c5f3c7 Mon Sep 17 00:00:00 2001 From: SESA741771 Date: Wed, 23 Apr 2025 14:03:45 +0200 Subject: [PATCH 5/6] src/schema_compile_node.c: coverity fix - wrong sizeof argument --- src/schema_compile_node.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c index a7e716888..b54a8f9a4 100644 --- a/src/schema_compile_node.c +++ b/src/schema_compile_node.c @@ -1701,7 +1701,8 @@ static LY_ERR lys_new_type(const struct ly_ctx *ctx, LY_DATA_TYPE basetype, const char *tpdf_name, struct lysc_type **type) { LY_ERR rc = LY_SUCCESS; - struct lysc_type *t = NULL; + void *t = NULL; + struct lysc_type *t2 = NULL; *type = NULL; @@ -1751,9 +1752,11 @@ lys_new_type(const struct ly_ctx *ctx, LY_DATA_TYPE basetype, const char *tpdf_n break; } LY_CHECK_ERR_GOTO(!t, LOGMEM(ctx); rc = LY_EMEM, cleanup); + /* memory is available then set to used pointer */ + t2 = (struct lysc_type *)t; if (tpdf_name) { - rc = lydict_insert(ctx, tpdf_name, 0, &t->name); + rc = lydict_insert(ctx, tpdf_name, 0, &t2->name); LY_CHECK_GOTO(rc, cleanup); } @@ -1761,7 +1764,7 @@ lys_new_type(const struct ly_ctx *ctx, LY_DATA_TYPE basetype, const char *tpdf_n if (rc) { free(t); } else { - *type = t; + *type = t2; } return rc; } From 0cb7d04ffe7a1a2823e24fbb82ca8b759a283d68 Mon Sep 17 00:00:00 2001 From: SESA741771 Date: Wed, 23 Apr 2025 16:04:06 +0200 Subject: [PATCH 6/6] src/parser_lyb.c: coverity fix - dereference after null check --- src/parser_lyb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser_lyb.c b/src/parser_lyb.c index 1622b5d99..453cab365 100644 --- a/src/parser_lyb.c +++ b/src/parser_lyb.c @@ -837,7 +837,7 @@ lyb_parse_schema_hash(struct lyd_lyb_ctx *lybctx, const struct lysc_node *sparen } else if (mod) { LOGVAL(lybctx->lybctx->ctx, LYVE_REFERENCE, "Failed to find matching hash for a top-level node" " from \"%s\".", mod->name); - } else { + } else if (sparent) { LOGVAL(lybctx->lybctx->ctx, LYVE_REFERENCE, "Failed to find matching hash for a child node" " of \"%s\".", sparent->name); }