[sr-dev] git:master:f6d69d87: app_lua: do lua_checkstack() to ensure enough capacity on Lua stack

Daniel-Constantin Mierla miconda at gmail.com
Mon Feb 12 08:24:47 CET 2018


Module: kamailio
Branch: master
Commit: f6d69d87abdc48df22135c79ee2309248248ca8e
URL: https://github.com/kamailio/kamailio/commit/f6d69d87abdc48df22135c79ee2309248248ca8e

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-02-12T08:24:28+01:00

app_lua: do lua_checkstack() to ensure  enough capacity on Lua stack

- Lua doesn't do automatic management of the stack
  * http://www.lua.org/manual/5.1/manual.html#3.2
- do exit on insufficient capacity
- based on the report by GH #1433

---

Modified: src/modules/app_lua/app_lua_sr.c

---

Diff:  https://github.com/kamailio/kamailio/commit/f6d69d87abdc48df22135c79ee2309248248ca8e.diff
Patch: https://github.com/kamailio/kamailio/commit/f6d69d87abdc48df22135c79ee2309248248ca8e.patch

---

diff --git a/src/modules/app_lua/app_lua_sr.c b/src/modules/app_lua/app_lua_sr.c
index 86380ec6ad..64ebafae40 100644
--- a/src/modules/app_lua/app_lua_sr.c
+++ b/src/modules/app_lua/app_lua_sr.c
@@ -1970,10 +1970,14 @@ void lua_sr_kemi_register_libs(lua_State *L)
 				}
 				n++;
 			}
+			if(!lua_checkstack(L, i+8)) {
+				LM_ERR("not enough Lua stack capacity\n");
+				exit(-1);
+			}
 			luaL_openlib(L, mname, _sr_crt_KSRMethods, 0);
-			LM_DBG("initializing kemi sub-module: %s (%s)\n", mname,
-					emods[k].kexp[0].mname.s);
+			LM_DBG("initializing kemi sub-module: %s (%s) (%d/%d/%d)\n", mname,
+					emods[k].kexp[0].mname.s, i, k, n);
 		}
 	}
-	LM_DBG("module 'KSR' has been initialized\n");
+	LM_DBG("module 'KSR' has been initialized (%d/%d)\n", emods_size, n);
 }




More information about the sr-dev mailing list