Module: kamailio
Branch: master
Commit: b43609dec2c4089e02b11fd23099ab01b2ebc956
URL:
https://github.com/kamailio/kamailio/commit/b43609dec2c4089e02b11fd23099ab0…
Author: Seudin Kasumovic <seudin.kasumovic(a)gmail.com>
Committer: Seudin Kasumovic <seudin.kasumovic(a)gmail.com>
Date: 2018-01-03T23:21:41+01:00
erlang: improve error handling
Ensure check value returned from function and log error.
---
Modified: src/modules/erlang/handle_emsg.c
Modified: src/modules/erlang/pv_xbuff.c
Modified: src/modules/erlang/worker.c
---
Diff:
https://github.com/kamailio/kamailio/commit/b43609dec2c4089e02b11fd23099ab0…
Patch:
https://github.com/kamailio/kamailio/commit/b43609dec2c4089e02b11fd23099ab0…
---
diff --git a/src/modules/erlang/handle_emsg.c b/src/modules/erlang/handle_emsg.c
index 1e36be5cb6..96de5e01d8 100644
--- a/src/modules/erlang/handle_emsg.c
+++ b/src/modules/erlang/handle_emsg.c
@@ -437,7 +437,11 @@ int erlang_whereis(cnode_handler_t *phandler,erlang_ref_ex_t *ref,
erlang_pid *p
return 0;
}
- ei_decode_atom(request->buff,&request->index,route+sizeof("erlang:")-1);
+ if(ei_decode_atom(request->buff,&request->index,route+sizeof("erlang:")-1))
{
+ LM_ERR("error: badarg\n");
+ ei_x_encode_atom(response,"badarg");
+ return 0;
+ }
rt = route_get(&event_rt, route);
if (rt < 0 || event_rt.rlist[rt] == NULL) {
@@ -820,7 +824,9 @@ int handle_erlang_msg(cnode_handler_t *phandler, erlang_msg * msg)
ret = handle_req_ref_tuple(phandler, msg);
break;
case ERL_PID_EXT:
- ei_decode_pid(request->buff,&tmpindex,&from);
+ if(ei_decode_pid(request->buff,&tmpindex,&from)) {
+ LM_ERR("failed to decode pid\n");
+ }
ret = handle_send(phandler, msg);
break;
default:
diff --git a/src/modules/erlang/pv_xbuff.c b/src/modules/erlang/pv_xbuff.c
index e8d26cdb9a..1682e52f3b 100644
--- a/src/modules/erlang/pv_xbuff.c
+++ b/src/modules/erlang/pv_xbuff.c
@@ -988,7 +988,10 @@ int xavp_decode(ei_x_buff *xbuff, int *index, sr_xavp_t **xavp,int
level)
return -1;
}
- ei_decode_atom(xbuff->buff,index,pbuf);
+ if (ei_decode_atom(xbuff->buff,index,pbuf)) {
+ LM_ERR("failed to decode atom\n");
+ goto err;
+ }
val.type = SR_XTYPE_STR;
val.v.s.s = pbuf;
diff --git a/src/modules/erlang/worker.c b/src/modules/erlang/worker.c
index 2a02e51df6..71af3b0298 100644
--- a/src/modules/erlang/worker.c
+++ b/src/modules/erlang/worker.c
@@ -59,7 +59,10 @@ int handle_worker(handler_common_t *phandler)
int rc;
/* ensure be connected */
- enode_connect();
+ if (enode_connect()){
+ LM_ERR("failed to connect!\n");
+ return -1;
+ }
memset((void*)&msg,0,sizeof(msg));