Skip to content

Commit

Permalink
Use common talloc_bstr_tolower function
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Oct 10, 2024
1 parent 1da33d5 commit 50986c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/lib/server/dl_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
/*
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/lib/util/talloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 50986c0

Please sign in to comment.