[sr-dev] git:master:15de1f06: app_lua: safer alloc size for hdr operations

Daniel-Constantin Mierla miconda at gmail.com
Fri Jul 14 14:52:54 CEST 2017


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-07-14T14:40:15+02:00

app_lua: safer alloc size for hdr operations

---

Modified: src/modules/app_lua/app_lua_sr.c

---

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

---

diff --git a/src/modules/app_lua/app_lua_sr.c b/src/modules/app_lua/app_lua_sr.c
index f999de3e37..86380ec6ad 100644
--- a/src/modules/app_lua/app_lua_sr.c
+++ b/src/modules/app_lua/app_lua_sr.c
@@ -737,7 +737,7 @@ static int lua_sr_hdr_append (lua_State *L)
 
 	hf = env_L->msg->last_header;
 	len = strlen(txt);
-	hdr = (char*)pkg_malloc(len);
+	hdr = (char*)pkg_malloc(len+1);
 	if(hdr==NULL)
 	{
 		LM_ERR("no pkg memory left\n");
@@ -823,7 +823,7 @@ static int lua_sr_hdr_insert (lua_State *L)
 	LM_DBG("insert hf: %s\n", txt);
 	hf = env_L->msg->headers;
 	len = strlen(txt);
-	hdr = (char*)pkg_malloc(len);
+	hdr = (char*)pkg_malloc(len+1);
 	if(hdr==NULL)
 	{
 		LM_ERR("no pkg memory left\n");
@@ -1683,7 +1683,6 @@ int sr_kemi_lua_exec_func_ex(lua_State* L, sr_kemi_t *ket, int pdelta)
 					fname->len, fname->s);
 			return app_lua_return_false(L);
 	}
-	return app_lua_return_false(L);
 }
 
 /**




More information about the sr-dev mailing list