Module: kamailio
Branch: 5.0
Commit: 8f2d55e21e1faeff43f6e48c2e8a6cd7c3450424
URL:
https://github.com/kamailio/kamailio/commit/8f2d55e21e1faeff43f6e48c2e8a6cd…
Author: Seudin Kasumovic <seudin.kasumovic(a)gmail.com>
Committer: Seudin Kasumovic <seudin.kasumovic(a)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/8f2d55e21e1faeff43f6e48c2e8a6cd…
Patch:
https://github.com/kamailio/kamailio/commit/8f2d55e21e1faeff43f6e48c2e8a6cd…
---
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)
{