Module: kamailio
Branch: master
Commit: f385148ff68e2125a2111d9c506022519f17d1c9
URL:
https://github.com/kamailio/kamailio/commit/f385148ff68e2125a2111d9c5060225…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-12-12T10:22:27+01:00
core: use one strlen for mod_path
---
Modified: src/core/sr_module.c
---
Diff:
https://github.com/kamailio/kamailio/commit/f385148ff68e2125a2111d9c5060225…
Patch:
https://github.com/kamailio/kamailio/commit/f385148ff68e2125a2111d9c5060225…
---
diff --git a/src/core/sr_module.c b/src/core/sr_module.c
index 6d50f294389..f19a2d3812b 100644
--- a/src/core/sr_module.c
+++ b/src/core/sr_module.c
@@ -410,12 +410,14 @@ int ksr_locate_module(char *mod_path, char **new_path)
int mdir_len;
int path_type;
int len;
+ int mod_path_len;
*new_path = NULL;
+ mod_path_len = strlen(mod_path);
path = mod_path;
path_type = 0;
modfile.s = path;
- modfile.len = strlen(mod_path);
+ modfile.len = mod_path_len;
modname.s = modfile.s;
if(modfile.len > 3 && strcmp(modfile.s + modfile.len - 3, ".so") ==
0) {
path_type = 1;
@@ -502,7 +504,7 @@ int ksr_locate_module(char *mod_path, char **new_path)
if(path == 0) {
/* try path <MODS_DIR>/mod_path - K compat */
path = (char *)pkg_malloc(
- mdir_len + 1 /* "/" */ + strlen(mod_path) + 1);
+ mdir_len + 1 /* "/" */ + mod_path_len + 1);
if(path == 0) {
PKG_MEM_ERROR;
goto error;
@@ -513,8 +515,8 @@ int ksr_locate_module(char *mod_path, char **new_path)
path[len] = '/';
len++;
}
- path[len] = 0;
- strcat(path, mod_path);
+ memcpy(path + len, mod_path, mod_path_len);
+ path[len + mod_path_len] = 0;
if(stat(path, &stat_buf) == -1) {
LM_DBG("module file not found <%s>\n", path);