]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
use macros to initialize fields instead of memset
authorAlan T. DeKok <aland@freeradius.org>
Fri, 18 Nov 2022 23:09:05 +0000 (18:09 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 21 Nov 2022 15:51:09 +0000 (10:51 -0500)
for the odd case where we cast a pre-existing value-box from
a string, AND that string is zero length, the cast silently
succeeds BUT leaves the destination value-box as FR_TYPE_NULL

Which seems bad

src/lib/util/value.c

index 85943383237a95e8274251a22f490516c6c267cb..aba8ac713d40e1084d0f5444de08fe169a4e2196 100644 (file)
@@ -3218,7 +3218,7 @@ int fr_value_box_cast(TALLOC_CTX *ctx, fr_value_box_t *dst,
        /*
         *      Initialise dst
         */
-       memset(dst, 0, sizeof(*dst));
+       fr_value_box_init(dst, dst_type, NULL, src->tainted);
 
        /*
         *      Dispatch to specialised cast functions
@@ -3311,7 +3311,7 @@ int fr_value_box_cast(TALLOC_CTX *ctx, fr_value_box_t *dst,
                        return -1;
                }
 
-               memset(&tmp, 0, sizeof(tmp));
+               fr_value_box_init(&tmp, dst_type, NULL, false);
 
                /*
                 *      Copy the raw octets into the datum of a value_box