From: Arran Cudbard-Bell Date: Thu, 10 Oct 2024 21:11:11 +0000 (-0400) Subject: Use common talloc_bstr_tolower function X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50986c0c0c19a16ca49cfc1652a6753b01d68969;p=thirdparty%2Ffreeradius-server.git Use common talloc_bstr_tolower function --- diff --git a/src/lib/server/dl_module.c b/src/lib/server/dl_module.c index 77876e9999e..74254176296 100644 --- a/src/lib/server/dl_module.c +++ b/src/lib/server/dl_module.c @@ -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); diff --git a/src/lib/util/talloc.h b/src/lib/util/talloc.h index 36b87cf73bc..5671361c543 100644 --- a/src/lib/util/talloc.h +++ b/src/lib/util/talloc.h @@ -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);