mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 11:42:27 +00:00
fix a seg fault due to assuming that space gets allocatted on the stack in the
same order that we declare the variables (issue #6290) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@8232 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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)
|
static int milliwatt_generate(struct ast_channel *chan, void *data, int len, int samples)
|
||||||
{
|
{
|
||||||
struct ast_frame wf;
|
struct ast_frame wf;
|
||||||
unsigned char waste[AST_FRIENDLY_OFFSET];
|
unsigned char buf[AST_FRIENDLY_OFFSET + 640];
|
||||||
unsigned char buf[640];
|
|
||||||
int i,*indexp = (int *) data;
|
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);
|
ast_log(LOG_WARNING,"Only doing %d bytes (%d bytes requested)\n",(int)(sizeof(buf) - AST_FRIENDLY_OFFSET),len);
|
||||||
len = sizeof(buf);
|
len = sizeof(buf) - AST_FRIENDLY_OFFSET;
|
||||||
}
|
}
|
||||||
waste[0] = 0; /* make compiler happy */
|
|
||||||
wf.frametype = AST_FRAME_VOICE;
|
wf.frametype = AST_FRAME_VOICE;
|
||||||
wf.subclass = AST_FORMAT_ULAW;
|
wf.subclass = AST_FORMAT_ULAW;
|
||||||
wf.offset = AST_FRIENDLY_OFFSET;
|
wf.offset = AST_FRIENDLY_OFFSET;
|
||||||
wf.mallocd = 0;
|
wf.mallocd = 0;
|
||||||
wf.data = buf;
|
wf.data = buf + AST_FRIENDLY_OFFSET;
|
||||||
wf.datalen = len;
|
wf.datalen = len;
|
||||||
wf.samples = wf.datalen;
|
wf.samples = wf.datalen;
|
||||||
wf.src = "app_milliwatt";
|
wf.src = "app_milliwatt";
|
||||||
wf.delivery.tv_sec = 0;
|
wf.delivery.tv_sec = 0;
|
||||||
wf.delivery.tv_usec = 0;
|
wf.delivery.tv_usec = 0;
|
||||||
|
wf.prev = wf.next = NULL;
|
||||||
/* create a buffer containing the digital milliwatt pattern */
|
/* create a buffer containing the digital milliwatt pattern */
|
||||||
for(i = 0; i < len; i++)
|
for(i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
buf[i] = digital_milliwatt[(*indexp)++];
|
buf[AST_FRIENDLY_OFFSET + i] = digital_milliwatt[(*indexp)++];
|
||||||
*indexp &= 7;
|
*indexp &= 7;
|
||||||
}
|
}
|
||||||
if (ast_write(chan,&wf) < 0)
|
if (ast_write(chan,&wf) < 0)
|
||||||
|
Reference in New Issue
Block a user