[sr-dev] git:5.0:8f2d55e2: erlang: fix possible memory corruption

Seudin Kasumovic seudin.kasumovic at gmail.com
Thu Jan 4 09:30:57 CET 2018


Module: kamailio
Branch: 5.0
Commit: 8f2d55e21e1faeff43f6e48c2e8a6cd7c3450424
URL: https://github.com/kamailio/kamailio/commit/8f2d55e21e1faeff43f6e48c2e8a6cd7c3450424

Author: Seudin Kasumovic <seudin.kasumovic at gmail.com>
Committer: Seudin Kasumovic <seudin.kasumovic at gmail.com>
Date: 2018-01-04T09:27:16+01:00

erlang: fix possible memory corruption

Allocate sufficient memory for the terminating null of the string.

(cherry picked from commit 13c71a14bfe4d2ee650521086bbae9920f95fcaa)

---

Modified: src/modules/erlang/handle_rpc.c

---

Diff:  https://github.com/kamailio/kamailio/commit/8f2d55e21e1faeff43f6e48c2e8a6cd7c3450424.diff
Patch: https://github.com/kamailio/kamailio/commit/8f2d55e21e1faeff43f6e48c2e8a6cd7c3450424.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