]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Do size calculation in appropriate type (CID #1604603)
authorJames Jones <jejones3141@gmail.com>
Thu, 27 Jun 2024 14:00:32 +0000 (09:00 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 27 Jun 2024 15:14:59 +0000 (11:14 -0400)
In the error message in lst_expand(), the calculation of the size
has to be done in size_t. The cast of sizeof(void *) to uint32_t
causes it to be done in uint32_t, but that has the possibility of
overflow; note that n_capacity may be set to UINT_MAX, which would
guarantee it. The format conversion is changed to match.

src/lib/util/lst.c

index 33064d04b5cd068b0d9f9a89c11a6e326eb80a94..9ff11a5f4cab988ce0b244c473485846cf38f05b 100644 (file)
@@ -418,8 +418,8 @@ static bool lst_expand(fr_lst_t *lst)
 
        n = talloc_realloc(lst, lst->p, void *, n_capacity);
        if (unlikely(!n)) {
-               fr_strerror_printf("Failed expanding lst to %u elements (%u bytes)",
-                                  n_capacity, n_capacity * (unsigned int)sizeof(void *));
+               fr_strerror_printf("Failed expanding lst to %u elements (%zu bytes)",
+                                  n_capacity, n_capacity * sizeof(void *));
                return false;
        }