[sr-dev] git:5.1:a262553c: erlang: fix use of an uninitialized variable
Seudin Kasumovic
seudin.kasumovic at gmail.com
Thu Jan 4 09:29:24 CET 2018
Module: kamailio
Branch: 5.1
Commit: a262553c9fe89f1543c9bf4275da3f9b07efada5
URL: https://github.com/kamailio/kamailio/commit/a262553c9fe89f1543c9bf4275da3f9b07efada5
Author: Seudin Kasumovic <seudin.kasumovic at gmail.com>
Committer: Seudin Kasumovic <seudin.kasumovic at gmail.com>
Date: 2018-01-04T09:23:21+01:00
erlang: fix use of an uninitialized variable
Ensure to initialize variable before use.
(cherry picked from commit a379ef730bc129b630325672c9a39aa8c59139b9)
---
Modified: src/modules/erlang/erl_helpers.c
Modified: src/modules/erlang/handle_emsg.c
Modified: src/modules/erlang/handle_rpc.c
---
Diff: https://github.com/kamailio/kamailio/commit/a262553c9fe89f1543c9bf4275da3f9b07efada5.diff
Patch: https://github.com/kamailio/kamailio/commit/a262553c9fe89f1543c9bf4275da3f9b07efada5.patch
---
diff --git a/src/modules/erlang/erl_helpers.c b/src/modules/erlang/erl_helpers.c
index ddc0abc952..8c7a391830 100644
--- a/src/modules/erlang/erl_helpers.c
+++ b/src/modules/erlang/erl_helpers.c
@@ -73,7 +73,6 @@ int erl_passive_socket(const char *hostname, int qlen,
int port;
struct addrinfo *ai;
struct addrinfo hints;
- struct ip_addr ip;
socklen_t addrlen = sizeof(struct sockaddr);
memset(&hints, 0, sizeof(struct addrinfo));
@@ -103,8 +102,7 @@ int erl_passive_socket(const char *hostname, int qlen,
/* initialize TCP */
#if !defined(TCP_DONT_REUSEADDR)
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(int))) {
- LM_ERR("failed to enable SO_REUSEADDR for socket on %s %s, %s\n",
- hostname, ip_addr2strz(&ip), strerror(errno));
+ LM_ERR("failed to enable SO_REUSEADDR: %s\n", strerror(errno));
}
#endif
/* tos */
@@ -118,8 +116,8 @@ int erl_passive_socket(const char *hostname, int qlen,
if (bind(sockfd, ai->ai_addr, ai->ai_addrlen) < 0)
{
port=sockaddr_port(ai->ai_addr);
- LM_CRIT("failed to bind socket on %s %s:%u. %s.\n", hostname,
- ip_addr2strz(&ip), port, strerror(errno));
+ LM_CRIT("failed to bind socket on %s:%u. %s.\n", hostname,
+ port, strerror(errno));
erl_close_socket(sockfd);
freeaddrinfo(ai);
@@ -128,8 +126,8 @@ int erl_passive_socket(const char *hostname, int qlen,
if (ai->ai_socktype == SOCK_STREAM && listen(sockfd, qlen) < 0)
{
- LM_CRIT("failed to listen socket on %s, %s. %s.\n", hostname,
- ip_addr2strz(&ip), strerror(errno));
+ LM_CRIT("failed to listen socket on %s: %s.\n", hostname,
+ strerror(errno));
erl_close_socket(sockfd);
freeaddrinfo(ai);
diff --git a/src/modules/erlang/handle_emsg.c b/src/modules/erlang/handle_emsg.c
index fe30b8d2ee..1e36be5cb6 100644
--- a/src/modules/erlang/handle_emsg.c
+++ b/src/modules/erlang/handle_emsg.c
@@ -640,6 +640,8 @@ int handle_rex_msg(cnode_handler_t *phandler, erlang_msg * msg)
ei_x_buff *request = &phandler->request;
ei_x_buff *response = &phandler->response;
+ memset((void*)&ref,0,sizeof(erlang_ref_ex_t));
+
/* start from first arg */
request->index = 0;
ei_decode_version(request->buff, &request->index, &version);
diff --git a/src/modules/erlang/handle_rpc.c b/src/modules/erlang/handle_rpc.c
index 5ca9ef21af..fccec06680 100644
--- a/src/modules/erlang/handle_rpc.c
+++ b/src/modules/erlang/handle_rpc.c
@@ -1138,6 +1138,8 @@ static int get_int(int *int_ptr,erl_rpc_ctx_t *ctx, int reads, int autoconvert)
return -1;
}
+ ei_decode_string(ctx->request->buff, &ctx->request_index, p);
+
*int_ptr = strtol(p,&endptr,10);
if (p == endptr)
{
@@ -1217,6 +1219,8 @@ static int get_double(double *double_prt,erl_rpc_ctx_t *ctx, int reads, int auto
return -1;
}
+ ei_decode_string(ctx->request->buff, &ctx->request_index, p);
+
*double_prt = strtod(p,&endptr);
if (p == endptr)
{
More information about the sr-dev
mailing list