]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix talloc foreach so it doesn't have issues with NULL input arrays
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 13 Apr 2023 21:48:20 +0000 (07:48 +1000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 13 Apr 2023 21:48:20 +0000 (07:48 +1000)
src/lib/util/talloc.h
src/modules/rlm_redis/rlm_redis.c

index 41c36359243ec34982b467d376927418d6c7b41f..582e493a6b8335086e0f4e259a906be131c91ff4 100644 (file)
@@ -73,7 +73,7 @@ talloc_foreach(vpt_m, vpt) {
  *                     Will be declared in the scope of the loop.
  */
 #define talloc_foreach(_array, _iter) \
-       for (__typeof__(_array[0]) _iter, *_p = (void *)(_array), *_end = (void *)((_array) + talloc_array_length(_array)); \
+       for (__typeof__(_array[0]) _iter, *_p = (void *)(_array), *_end = _array ? (void *)((_array) + talloc_array_length(_array)) : NULL; \
             (_p < _end) && (_iter = *((void **)(uintptr_t)(_p))); \
             _p = (__typeof__(_p))((__typeof__(_array))_p) + 1)
 
index df54f9cb540c914ba89d7ce24f28f67a2e7099c3..d9bea2dfde4f99be29965fed57b69b0407bf4318 100644 (file)
@@ -840,7 +840,6 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
         *      Loop over the lua functions, registering an xlat
         *      that'll call that function specifically.
         */
-       if (!inst->lua.funcs) return 0;
        talloc_foreach(inst->lua.funcs, func) {
                name = talloc_asprintf(NULL, "%s.%s", mctx->inst->name, func->name);
                if (unlikely((xlat = xlat_func_register_module(inst, mctx, name, redis_lua_func_xlat, FR_TYPE_VOID)) == NULL)) return -1;