Module: sip-router
Branch: master
Commit: 53605f2ca1718e42f1f1fcb87bb67935c889249a
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=53605f2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Sun Jul 17 00:28:26 2011 +0200
app_python: provide a clone string to dirname and basename
- script name value is cloned before execution of dirname and basename
since they may modify the parameter
- reported by Arnaud Chong, FS#137
---
modules/app_python/python_mod.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/modules/app_python/python_mod.c b/modules/app_python/python_mod.c
index f943e07..c89c928 100644
--- a/modules/app_python/python_mod.c
+++ b/modules/app_python/python_mod.c
@@ -85,7 +85,7 @@ struct module_exports exports = {
static int
mod_init(void)
{
- char *dname, *bname;
+ char *dname, *bname, *tname;
int i;
PyObject *sys_path, *pDir, *pModule, *pFunc, *pArgs;
PyThreadState *mainThreadState;
@@ -100,11 +100,19 @@ mod_init(void)
child_init_mname.len = strlen(child_init_mname.s);
}
- dname = dirname(script_name.s);
+ tname = as_asciiz(&script_name);
+ if(tname==NULL)
+ {
+ LM_ERR("no more pkg memory\n");
+ return -1;
+ }
+ dname = dirname(tname);
if (strlen(dname) == 0)
dname = ".";
- bname = basename(script_name.s);
+ memcpy(tname, script_name.s, script_name.len);
+ bname = basename(tname);
i = strlen(bname);
+ pkg_free(tname);
if (bname[i - 1] == 'c' || bname[i - 1] == 'o')
i -= 1;
if (bname[i - 3] == '.' && bname[i - 2] == 'p' &&
bname[i - 1] == 'y') {