[sr-dev] git:master:13c71a14: erlang: fix possible memory corruption

Seudin Kasumovic seudin.kasumovic at gmail.com
Wed Jan 3 23:25:29 CET 2018


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

Author: Seudin Kasumovic <seudin.kasumovic at gmail.com>
Committer: Seudin Kasumovic <seudin.kasumovic at gmail.com>
Date: 2018-01-03T23:21:41+01:00

erlang: fix possible memory corruption

Allocate sufficient memory for the terminating null of the string.

---

Modified: src/modules/erlang/handle_rpc.c

---

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

---

diff --git a/src/modules/erlang/handle_rpc.c b/src/modules/erlang/handle_rpc.c
index 5fe3c1f978..b852892d9d 100644
--- a/src/modules/erlang/handle_rpc.c
+++ b/src/modules/erlang/handle_rpc.c
@@ -223,7 +223,7 @@ int erl_rpc_add(erl_rpc_ctx_t* ctx, char* fmt, ...)
 			param->type = ERL_STRING_EXT;
 			param->value.S.len = strlen(char_ptr);
 
-			param->value.S.s = (char*)pkg_malloc(param->value.S.len);
+			param->value.S.s = (char*)pkg_malloc(param->value.S.len+1);
 
 			if (!param->value.S.s)
 			{
@@ -696,7 +696,7 @@ int erl_rpc_struct_add(erl_rpc_ctx_t* ctx, char* fmt, ...)
 			param->type = ERL_STRING_EXT;
 			param->value.S.len = strlen(char_ptr);
 
-			param->value.S.s = (char*)pkg_malloc(param->value.S.len);
+			param->value.S.s = (char*)pkg_malloc(param->value.S.len+1);
 
 			if (!param->value.S.s)
 			{
@@ -847,7 +847,7 @@ int erl_rpc_array_add(erl_rpc_ctx_t* ctx, char* fmt, ...)
 			param->type = ERL_STRING_EXT;
 			param->value.S.len = strlen(char_ptr);
 
-			param->value.S.s = (char*)pkg_malloc(param->value.S.len);
+			param->value.S.s = (char*)pkg_malloc(param->value.S.len+1);
 
 			if (!param->value.S.s)
 			{




More information about the sr-dev mailing list