Module: kamailio
Branch: 5.1
Commit: 867f8d18ed2a1c8c2af4e382942ca0d15789e8cb
URL:
https://github.com/kamailio/kamailio/commit/867f8d18ed2a1c8c2af4e382942ca0d…
Author: Seudin Kasumovic <seudin.kasumovic(a)gmail.com>
Committer: Seudin Kasumovic <seudin.kasumovic(a)gmail.com>
Date: 2018-01-04T09:24:43+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/867f8d18ed2a1c8c2af4e382942ca0d…
Patch:
https://github.com/kamailio/kamailio/commit/867f8d18ed2a1c8c2af4e382942ca0d…
---
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)
{