]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use common talloc_bstr_tolower function
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 10 Oct 2024 21:11:11 +0000 (17:11 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 10 Oct 2024 22:25:18 +0000 (18:25 -0400)
src/lib/server/dl_module.c
src/lib/util/talloc.h

index 77876e9999e87ef67238ab17b100c1a0aeb22aab..742541762963c4cfc46f723070b93ccf301f9c36 100644 (file)
@@ -317,7 +317,6 @@ dl_module_t *dl_module_alloc(dl_module_t const *parent, char const *name, dl_mod
        dl_module_t                     *dl_module = NULL;
        dl_t                            *dl = NULL;
        char                            *module_name = NULL;
-       char                            *p, *q;
        dl_module_common_t              *common;
 
        DL_INIT_CHECK;
@@ -332,9 +331,12 @@ dl_module_t *dl_module_alloc(dl_module_t const *parent, char const *name, dl_mod
                                                    name);
        }
 
-       if (!module_name) return NULL;
+       if (!module_name) {
+               fr_strerror_const("Out of memory");
+               return NULL;
+       }
 
-       for (p = module_name, q = p + talloc_array_length(p) - 1; p < q; p++) *p = tolower((uint8_t) *p);
+       talloc_bstr_tolower(module_name);
 
        pthread_mutex_lock(&dl_module_loader->lock);
        /*
@@ -588,7 +590,8 @@ dl_module_loader_t *dl_module_loader_init(char const *lib_dir)
                                   DL_PRIORITY_DICT, "dict", fr_dl_dict_autofree, NULL);
 
        /*
-        *      Register library autoload callbacks
+        *      Register library autoload callbacks for registering
+        *      global configuration sections.
         */
        dl_symbol_init_cb_register(dl_module_loader->dl_loader,
                                   DL_PRIORITY_LIB, "lib", global_lib_auto_instantiate, NULL);
index 36b87cf73bc2d93c9162133de910911f101a4f6c..5671361c5430390cfee2378bb658ab56c569b211 100644 (file)
@@ -121,6 +121,17 @@ static inline TALLOC_CTX *talloc_init_const(char const *name)
        return ctx;
 }
 
+/** Convert a talloced string to lowercase
+ *
+ * @param[in] str      to convert.
+ */
+static inline void talloc_bstr_tolower(char *str)
+{
+       char *p, *q;
+
+       for (p = str, q = p + (talloc_array_length(str) - 1); p < q; p++) *p = tolower((uint8_t) *p);
+}
+
 void           talloc_free_data(void *data);
 
 void           *talloc_null_ctx(void);