Merged revisions 100465 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r100465 | tilghman | 2008-01-27 15:59:53 -0600 (Sun, 27 Jan 2008) | 11 lines

When deleting a task from the scheduler, ignoring the return value could
possibly cause memory to be accessed after it is freed, which causes all
sorts of random memory corruption.  Instead, if a deletion fails, wait a
bit and try again (noting that another thread could change our taskid
value).
(closes issue #11386)
 Reported by: flujan
 Patches: 
       20080124__bug11386.diff.txt uploaded by Corydon76 (license 14)
 Tested by: Corydon76, flujan, stuarth`

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@100488 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2008-01-27 22:35:29 +00:00
parent aa9c40236c
commit ac699196f5
11 changed files with 123 additions and 204 deletions

View File

@@ -2374,10 +2374,7 @@ struct ast_rtp *ast_rtp_get_bridged(struct ast_rtp *rtp)
void ast_rtp_stop(struct ast_rtp *rtp)
{
if (rtp->rtcp && rtp->rtcp->schedid > 0) {
ast_sched_del(rtp->sched, rtp->rtcp->schedid);
rtp->rtcp->schedid = -1;
}
AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid);
memset(&rtp->them.sin_addr, 0, sizeof(rtp->them.sin_addr));
memset(&rtp->them.sin_port, 0, sizeof(rtp->them.sin_port));
@@ -2507,8 +2504,7 @@ void ast_rtp_destroy(struct ast_rtp *rtp)
if (rtp->s > -1)
close(rtp->s);
if (rtp->rtcp) {
if (rtp->rtcp->schedid > 0)
ast_sched_del(rtp->sched, rtp->rtcp->schedid);
AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid);
close(rtp->rtcp->s);
ast_free(rtp->rtcp);
rtp->rtcp=NULL;
@@ -2734,9 +2730,7 @@ static int ast_rtcp_write_sr(const void *data)
if (!rtp->rtcp->them.sin_addr.s_addr) { /* This'll stop rtcp for this rtp session */
ast_verbose("RTCP SR transmission error, rtcp halted\n");
if (rtp->rtcp->schedid > 0)
ast_sched_del(rtp->sched, rtp->rtcp->schedid);
rtp->rtcp->schedid = -1;
AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid);
return 0;
}
@@ -2793,9 +2787,7 @@ static int ast_rtcp_write_sr(const void *data)
res = sendto(rtp->rtcp->s, (unsigned int *)rtcpheader, len, 0, (struct sockaddr *)&rtp->rtcp->them, sizeof(rtp->rtcp->them));
if (res < 0) {
ast_log(LOG_ERROR, "RTCP SR transmission error to %s:%d, rtcp halted %s\n",ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port), strerror(errno));
if (rtp->rtcp->schedid > 0)
ast_sched_del(rtp->sched, rtp->rtcp->schedid);
rtp->rtcp->schedid = -1;
AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid);
return 0;
}
@@ -2868,9 +2860,7 @@ static int ast_rtcp_write_rr(const void *data)
if (!rtp->rtcp->them.sin_addr.s_addr) {
ast_log(LOG_ERROR, "RTCP RR transmission error, rtcp halted\n");
if (rtp->rtcp->schedid > 0)
ast_sched_del(rtp->sched, rtp->rtcp->schedid);
rtp->rtcp->schedid = -1;
AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid);
return 0;
}
@@ -2917,9 +2907,7 @@ static int ast_rtcp_write_rr(const void *data)
if (res < 0) {
ast_log(LOG_ERROR, "RTCP RR transmission error, rtcp halted: %s\n",strerror(errno));
/* Remove the scheduler */
if (rtp->rtcp->schedid > 0)
ast_sched_del(rtp->sched, rtp->rtcp->schedid);
rtp->rtcp->schedid = -1;
AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid);
return 0;
}