diff options
-rw-r--r-- | apps/app_milliwatt.c | 15 | ||||
-rw-r--r-- | channels/chan_sip.c | 3 |
2 files changed, 9 insertions, 9 deletions
diff --git a/apps/app_milliwatt.c b/apps/app_milliwatt.c index 5ef708c1f..9c46689f4 100644 --- a/apps/app_milliwatt.c +++ b/apps/app_milliwatt.c @@ -73,30 +73,29 @@ static void milliwatt_release(struct ast_channel *chan, void *data) static int milliwatt_generate(struct ast_channel *chan, void *data, int len, int samples) { struct ast_frame wf; - unsigned char waste[AST_FRIENDLY_OFFSET]; - unsigned char buf[640]; + unsigned char buf[AST_FRIENDLY_OFFSET + 640]; int i,*indexp = (int *) data; - if (len > sizeof(buf)) + if (len + AST_FRIENDLY_OFFSET > sizeof(buf)) { - ast_log(LOG_WARNING,"Only doing %d bytes (%d bytes requested)\n",(int)sizeof(buf),len); - len = sizeof(buf); + ast_log(LOG_WARNING,"Only doing %d bytes (%d bytes requested)\n",(int)(sizeof(buf) - AST_FRIENDLY_OFFSET),len); + len = sizeof(buf) - AST_FRIENDLY_OFFSET; } - waste[0] = 0; /* make compiler happy */ wf.frametype = AST_FRAME_VOICE; wf.subclass = AST_FORMAT_ULAW; wf.offset = AST_FRIENDLY_OFFSET; wf.mallocd = 0; - wf.data = buf; + wf.data = buf + AST_FRIENDLY_OFFSET; wf.datalen = len; wf.samples = wf.datalen; wf.src = "app_milliwatt"; wf.delivery.tv_sec = 0; wf.delivery.tv_usec = 0; + wf.prev = wf.next = NULL; /* create a buffer containing the digital milliwatt pattern */ for(i = 0; i < len; i++) { - buf[i] = digital_milliwatt[(*indexp)++]; + buf[AST_FRIENDLY_OFFSET + i] = digital_milliwatt[(*indexp)++]; *indexp &= 7; } if (ast_write(chan,&wf) < 0) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 24872fe48..b5b5ae148 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -5200,13 +5200,14 @@ static int transmit_notify_with_mwi(struct sip_pvt *p, int newmsgs, int oldmsgs, char tmp[500]; char *t = tmp; size_t maxbytes = sizeof(tmp); + char iabuf[INET_ADDRSTRLEN]; initreqprep(&req, p, SIP_NOTIFY); add_header(&req, "Event", "message-summary"); add_header(&req, "Content-Type", default_notifymime); ast_build_string(&t, &maxbytes, "Messages-Waiting: %s\r\n", newmsgs ? "yes" : "no"); - ast_build_string(&t, &maxbytes, "Message-Account: sip:%s@%s\r\n", !ast_strlen_zero(vmexten) ? vmexten : global_vmexten, p->fromdomain); + ast_build_string(&t, &maxbytes, "Message-Account: sip:%s@%s\r\n", !ast_strlen_zero(vmexten) ? vmexten : global_vmexten, ast_strlen_zero(p->fromdomain) ? ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip) : p->fromdomain); ast_build_string(&t, &maxbytes, "Voice-Message: %d/%d (0/0)\r\n", newmsgs, oldmsgs); if (t > tmp + sizeof(tmp)) |