Module: kamailio
Branch: master
Commit: cc661d776621a5f2d4370eb364402c2a53242cc7
URL:
https://github.com/kamailio/kamailio/commit/cc661d776621a5f2d4370eb364402c2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-03-30T17:23:29+02:00
app_lua: test if number of parameters is enough for kemi funtions
---
Modified: src/modules/app_lua/app_lua_sr.c
---
Diff:
https://github.com/kamailio/kamailio/commit/cc661d776621a5f2d4370eb364402c2…
Patch:
https://github.com/kamailio/kamailio/commit/cc661d776621a5f2d4370eb364402c2…
---
diff --git a/src/modules/app_lua/app_lua_sr.c b/src/modules/app_lua/app_lua_sr.c
index 64ebafae40..72d2eb0ddf 100644
--- a/src/modules/app_lua/app_lua_sr.c
+++ b/src/modules/app_lua/app_lua_sr.c
@@ -1489,9 +1489,27 @@ int sr_kemi_lua_exec_func_ex(lua_State* L, sr_kemi_t *ket, int
pdelta)
for(i=0; i<SR_KEMI_PARAMS_MAX; i++) {
if(ket->ptypes[i]==SR_KEMIP_NONE) {
break;
- } else if(ket->ptypes[i]==SR_KEMIP_STR) {
+ }
+ if(argc<i+pdelta+1) {
+ LM_ERR("not enough parameters for: %.*s.%.*s\n",
+ mname->len, mname->s, fname->len, fname->s);
+ return app_lua_return_false(L);
+ }
+ if(ket->ptypes[i]==SR_KEMIP_STR) {
vps[i].s.s = (char*)lua_tostring(L, i+pdelta+1);
- vps[i].s.len = strlen(vps[i].s.s);
+ if(vps[i].s.s!=NULL) {
+ if(lua_isstring(L, i+pdelta+1)) {
+#if LUA_VERSION_NUM > 501
+ vps[i].s.len = lua_rawlen(L, i+pdelta+1);
+#else
+ vps[i].s.len = lua_strlen(L, i+pdelta+1);
+#endif
+ } else {
+ vps[i].s.len = strlen(vps[i].s.s);
+ }
+ } else {
+ vps[i].s.len = 0;
+ }
LM_DBG("param[%d] for: %.*s is str: %.*s\n", i,
fname->len, fname->s, vps[i].s.len, vps[i].s.s);
} else if(ket->ptypes[i]==SR_KEMIP_INT) {