summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzuul <zuul@gerrit.asterisk.org>2016-03-03 14:51:10 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2016-03-03 14:51:10 -0600
commit6705f308cb075dd1319924a1fc70590e69a14fca (patch)
treed6d1d640b3736a001cac0c2836eec9e12e4e0080
parent7023055def57fe63bb169c481c801c72599d3fdb (diff)
parent6af7fc4c37b314ba2bf3380d44c7e4ac409787e2 (diff)
Merge "res_pjsip_dtmf_info: NULL terminate the message body."
-rw-r--r--res/res_pjsip_dtmf_info.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/res/res_pjsip_dtmf_info.c b/res/res_pjsip_dtmf_info.c
index 78d529c30..47ccd1ae5 100644
--- a/res/res_pjsip_dtmf_info.c
+++ b/res/res_pjsip_dtmf_info.c
@@ -82,14 +82,13 @@ static char get_event(const char *c)
static int dtmf_info_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
{
pjsip_msg_body *body = rdata->msg_info.msg->body;
- char buf[body ? body->len : 0];
+ char buf[body ? body->len + 1 : 1];
char *cur = buf;
char *line;
-
char event = '\0';
unsigned int duration = 100;
-
char is_dtmf;
+ int res;
if (!session->channel) {
return 0;
@@ -107,7 +106,12 @@ static int dtmf_info_incoming_request(struct ast_sip_session *session, struct pj
return 0;
}
- body->print_body(body, buf, body->len);
+ res = body->print_body(body, buf, body->len);
+ if (res < 0) {
+ send_response(session, rdata, 500);
+ return 0;
+ }
+ buf[res] = '\0';
if (is_dtmf) {
/* directly use what is in the message body */