From e6f928ca79ca727fd05a0239d8e5ac1eb4e0a93f Mon Sep 17 00:00:00 2001 From: Tamas Cseke Date: Tue, 22 Nov 2016 15:30:19 +0100 Subject: [PATCH] Remove arg limit Allocate dynamically FS-9762 --resolve --- .../event_handlers/mod_erlang_event/handle_msg.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mod/event_handlers/mod_erlang_event/handle_msg.c b/src/mod/event_handlers/mod_erlang_event/handle_msg.c index 5dbcd202c1..06344e721f 100644 --- a/src/mod/event_handlers/mod_erlang_event/handle_msg.c +++ b/src/mod/event_handlers/mod_erlang_event/handle_msg.c @@ -737,13 +737,18 @@ static switch_status_t handle_msg_api(listener_t *listener, erlang_msg * msg, in } } -#define ARGLEN 2048 static switch_status_t handle_msg_bgapi(listener_t *listener, erlang_msg * msg, int arity, ei_x_buff * buf, ei_x_buff * rbuf) { char api_cmd[MAXATOMLEN]; - char arg[ARGLEN]; + char *arg = NULL; + int size, type; + + if (arity < 3 || + ei_decode_atom(buf->buff, &buf->index, api_cmd) || + ei_get_type(buf->buff, &buf->index, &type, &size) || + !(arg = malloc(size + 1)) || + ei_decode_string_or_binary(buf->buff, &buf->index, size, arg)) { - if (arity < 3 || ei_decode_atom(buf->buff, &buf->index, api_cmd) || ei_decode_string_or_binary(buf->buff, &buf->index, ARGLEN - 1, arg)) { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "badarg"); @@ -776,6 +781,9 @@ static switch_status_t handle_msg_bgapi(listener_t *listener, erlang_msg * msg, ei_x_encode_atom(rbuf, "ok"); _ei_x_encode_string(rbuf, acs->uuid_str); } + + switch_safe_free(arg); + return SWITCH_STATUS_SUCCESS; }