[sr-dev] git:master:6c8d6185: imc: safety checks for function parameters
Daniel-Constantin Mierla
miconda at gmail.com
Wed Apr 14 12:41:26 CEST 2021
Module: kamailio
Branch: master
Commit: 6c8d61850aa662016d952f25dc510ed4d602e10c
URL: https://github.com/kamailio/kamailio/commit/6c8d61850aa662016d952f25dc510ed4d602e10c
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-04-14T12:40:19+02:00
imc: safety checks for function parameters
---
Modified: src/modules/imc/imc_cmd.c
---
Diff: https://github.com/kamailio/kamailio/commit/6c8d61850aa662016d952f25dc510ed4d602e10c.diff
Patch: https://github.com/kamailio/kamailio/commit/6c8d61850aa662016d952f25dc510ed4d602e10c.patch
---
diff --git a/src/modules/imc/imc_cmd.c b/src/modules/imc/imc_cmd.c
index 94ddc38884..8d9c6f3ea1 100644
--- a/src/modules/imc/imc_cmd.c
+++ b/src/modules/imc/imc_cmd.c
@@ -488,6 +488,10 @@ int imc_handle_join(struct sip_msg* msg, imc_cmd_t *cmd,
str body;
struct imc_uri room;
+ if(cmd==NULL || src==NULL || dst==NULL) {
+ return -1;
+ }
+
memset(&room, '\0', sizeof(room));
if (build_imc_uri(&room, cmd->param[0].s ? cmd->param[0] : dst->parsed.user, &dst->parsed))
goto error;
@@ -537,12 +541,14 @@ int imc_handle_join(struct sip_msg* msg, imc_cmd_t *cmd,
goto error;
}
- body.len = snprintf(body.s, sizeof(imc_body_buf), msg_user_joined.s, STR_FMT(format_uri(src->uri)));
+ body.len = snprintf(body.s, sizeof(imc_body_buf), msg_user_joined.s,
+ STR_FMT(format_uri(src->uri)));
} else {
LM_DBG("Attept to join private room [%.*s] by [%.*s]\n",
STR_FMT(&rm->uri), STR_FMT(&src->uri));
- body.len = snprintf(body.s, sizeof(imc_body_buf), msg_join_attempt_bcast.s, STR_FMT(format_uri(src->uri)));
+ body.len = snprintf(body.s, sizeof(imc_body_buf), msg_join_attempt_bcast.s,
+ STR_FMT(format_uri(src->uri)));
imc_send_message(&rm->uri, &src->uri, build_headers(msg), &msg_join_attempt_ucast);
}
@@ -563,7 +569,7 @@ int imc_handle_join(struct sip_msg* msg, imc_cmd_t *cmd,
rv = 0;
error:
- if (room.uri.s) pkg_free(room.uri.s);
+ if (room.uri.s != NULL) pkg_free(room.uri.s);
if (rm != NULL) imc_release_room(rm);
return rv;
}
More information about the sr-dev
mailing list