]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: fix coverity issues
authorChristian Hopps <chopps@labn.net>
Thu, 11 Jan 2024 15:38:58 +0000 (15:38 +0000)
committerChristian Hopps <chopps@labn.net>
Thu, 11 Jan 2024 18:14:58 +0000 (18:14 +0000)
** 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 <chopps@labn.net>
lib/darr.h
lib/yang.c
mgmtd/mgmt_fe_adapter.c

index df8ace62dd153d69fe7db2eb1ae4af9c9e5efd10..404869d9a252d2b6169e4b71b4a7ccf4b04d181d 100644 (file)
@@ -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);                      \
index 2860108d6454b2d0f8b6de3cb695199fd3fe191b..5b177f7fbcff104cd976b041fbeec7d85b51f674 100644 (file)
@@ -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
index b7c7a0fff1470f3b8bc375556a6797d3e181219e..a69d27fc5c58b3a1b738b2366b81f8d673645201 100644 (file)
@@ -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;