diff options
author | zuul <zuul@gerrit.asterisk.org> | 2016-03-03 14:51:12 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2016-03-03 14:51:13 -0600 |
commit | 039ea76a8a47a4b1464dcdb3b46161d5320bf4e9 (patch) | |
tree | c5c19b153b8d5c347b798bbaeb91555b16031de0 | |
parent | 9e896540c82f88451d25e5d046b104a76526f864 (diff) | |
parent | 26b8f2692e43ab382153fbb29c138427994ded92 (diff) |
Merge "res_pjsip_dtmf_info: NULL terminate the message body." into 13
-rw-r--r-- | res/res_pjsip_dtmf_info.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/res/res_pjsip_dtmf_info.c b/res/res_pjsip_dtmf_info.c index 7b52250c8..ede515d1c 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 */ |