]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Don't use the unsafe value box copy macro
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 11 Dec 2022 21:04:48 +0000 (15:04 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 11 Dec 2022 21:04:48 +0000 (15:04 -0600)
src/lib/redis/redis.c
src/lib/util/value.h
src/modules/rlm_rest/rest.c

index d8d82cc28ed4d9ace177cc57d0c58b1a9b2bc968..888ef6b6efed70e9ed90c85da87afa3befe4fb74 100644 (file)
@@ -25,6 +25,7 @@
  */
 #include <freeradius-devel/redis/base.h>
 #include <freeradius-devel/util/debug.h>
+#include <freeradius-devel/util/value.h>
 
 fr_table_num_sorted_t const redis_reply_types[] = {
        { L("array"),           REDIS_REPLY_ARRAY       },
@@ -210,7 +211,7 @@ int fr_redis_reply_to_value_box(TALLOC_CTX *ctx, fr_value_box_t *out, redisReply
        fr_value_box_t  *to_cast;
 
        if (dst_type != FR_TYPE_VOID) {
-               fr_value_box_copy_unsafe(&in, &(fr_value_box_t){});
+               fr_value_box_init_null(&in);
                to_cast = &in;
        } else {
                to_cast = out;
index f24625dec2b8e96645f11bcbcdf2db519422f155..13150e485dbcb17bdbaeaf05b1159bcfefcf3482 100644 (file)
@@ -419,17 +419,6 @@ void               fr_value_box_copy_shallow(TALLOC_CTX *ctx, fr_value_box_t *dst,
                                          const fr_value_box_t *src)
                CC_HINT(nonnull(2,3));
 
-/*
- *     fr_value_box_copy_unsafe() copies the raw bytes from one value box
- *     to another. Its uses are rare.
- */
-static inline CC_HINT(nonnull, always_inline)
-void           fr_value_box_copy_unsafe(fr_value_box_t *dst, const fr_value_box_t *src)
-{
-       /* coverity[store_writes_const_field] */
-       memcpy(dst, src, sizeof(*dst));
-}
-
 int            fr_value_box_steal(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t *src)
                CC_HINT(nonnull(2,3));
 /** @} */
@@ -454,11 +443,11 @@ int               fr_value_box_steal(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t *sr
 static inline CC_HINT(nonnull(1), always_inline)
 void fr_value_box_init(fr_value_box_t *vb, fr_type_t type, fr_dict_attr_t const *enumv, bool tainted)
 {
-       fr_value_box_copy_unsafe(vb, &(fr_value_box_t){
-               .type = type,
-               .enumv = enumv,
-               .tainted = tainted
-       });
+       memcpy(vb, &(fr_value_box_t){
+                       .type = type,
+                       .enumv = enumv,
+                       .tainted = tainted
+              }, sizeof(*vb));
        fr_value_box_list_entry_init(vb);
 
        /*
index 982de5ef1d0e898b5db3f00a559237ae8b854a8b..01608f6b10b41dae736d77badb651b15bf0bb28b 100644 (file)
@@ -23,6 +23,7 @@
  * @copyright 2012-2021 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
  */
 
+
 RCSID("$Id$")
 
 #define LOG_PREFIX mctx->inst->name
@@ -34,6 +35,7 @@ RCSID("$Id$")
 #include <freeradius-devel/server/base.h>
 #include <freeradius-devel/server/pool.h>
 #include <freeradius-devel/unlang/call.h>
+#include <freeradius-devel/unlang/value.h>
 
 #include "rest.h"
 
@@ -869,7 +871,7 @@ static fr_pair_t *json_pair_alloc_leaf(UNUSED rlm_rest_t const *instance, UNUSED
                return NULL;
        }
 
-       fr_value_box_copy_unsafe(&src, &(fr_value_box_t){});
+       fr_value_box_init_null(&src);
 
        switch (json_object_get_type(leaf)) {
        case json_type_int: