From: Christian Hopps Date: Thu, 11 Jan 2024 15:38:58 +0000 (+0000) Subject: lib: fix coverity issues X-Git-Tag: base_10.0~126^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=29f2a300a328974146230c320ef63d047a679e81;p=matthieu%2Ffrr.git lib: fix coverity issues ** CID 1575504: Insecure data handling (TAINTED_SCALAR) (maybe) ** CID 1575505: Integer handling issues (CONSTANT_EXPRESSION_RESULT) ** CID 1575506: Integer handling issues (CONSTANT_EXPRESSION_RESULT) ** CID 1575507: Null pointer dereferences (REVERSE_INULL) Signed-off-by: Christian Hopps --- diff --git a/lib/darr.h b/lib/darr.h index df8ace62dd..404869d9a2 100644 --- a/lib/darr.h +++ b/lib/darr.h @@ -291,7 +291,7 @@ void *__darr_resize(void *a, uint count, size_t esize, struct memtype *mt); */ #define darr_ensure_i_mt(A, I, MT) \ ({ \ - assert((int)(I) >= 0 && (int)(I) <= INT_MAX); \ + assert((int)(I) >= 0 && (uint)(I) <= INT_MAX); \ int _i = (int)(I); \ if (_i > darr_maxi(A)) \ _darr_resize_mt((A), _i + 1, MT); \ diff --git a/lib/yang.c b/lib/yang.c index 2860108d64..5b177f7fbc 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -1143,8 +1143,7 @@ LY_ERR yang_lyd_trim_xpath(struct lyd_node **root, const char *xpath) } darr_free(remove); - if (set) - ly_set_free(set, NULL); + ly_set_free(set, NULL); return LY_SUCCESS; #endif diff --git a/mgmtd/mgmt_fe_adapter.c b/mgmtd/mgmt_fe_adapter.c index b7c7a0fff1..a69d27fc5c 100644 --- a/mgmtd/mgmt_fe_adapter.c +++ b/mgmtd/mgmt_fe_adapter.c @@ -1087,7 +1087,7 @@ static int fe_adapter_send_tree_data(struct mgmt_fe_session_ctx *session, uint8_t *buf = NULL; int ret = 0; - darr_append_n(buf, offsetof(typeof(*msg), result)); + darr_append_n(buf, sizeof(*msg)); msg = (typeof(msg))buf; msg->refer_id = session->session_id; msg->req_id = req_id;