summaryrefslogtreecommitdiff
path: root/res/res_pjsip_dtmf_info.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2016-03-03 10:26:10 -0400
committerJoshua Colp <jcolp@digium.com>2016-03-03 12:42:57 -0400
commit26b8f2692e43ab382153fbb29c138427994ded92 (patch)
tree65e9dd14d825b18bd61f27d36878be9e7fd37bd1 /res/res_pjsip_dtmf_info.c
parent3b6b164f2ec1df09337fe33e92e74757e4acfb9f (diff)
res_pjsip_dtmf_info: NULL terminate the message body.
PJSIP does not ensure that when printing the message body the buffer will be NULL terminated. This is problematic when searching for the signal and duration values of the DTMF. This change ensures the buffer is always NULL terminated. Change-Id: I52653a1a60c93092d06af31a27408d569cc98968
Diffstat (limited to 'res/res_pjsip_dtmf_info.c')
-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 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 */