diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-03-25 17:05:40 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-03-25 17:05:40 +0000 |
commit | 1e4fccc0ce0d999e98d7c0c72046be7098b135c0 (patch) | |
tree | 8e1a590a10bb9a93f44baa767c8c3739847b7752 | |
parent | 4dd5afa6b884e4969becb335557b1de3d2c5c487 (diff) |
Fix crashes resulting from reading non-existent RTP streams.
Specifically, when using the CHANNEL dialplan function, it was
possible to crash Asterisk by trying to get the rtpdest of a
stream type that is not in use by the channel. This commit
fixes that issue.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@254540 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_sip.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 9878a2c31..c1f438fa5 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -19064,17 +19064,24 @@ static int acf_channel_read(struct ast_channel *chan, const char *funcname, char if (!strcasecmp(args.param, "rtpdest")) { struct sockaddr_in sin; + struct ast_rtp *stream; if (ast_strlen_zero(args.type)) args.type = "audio"; - if (!strcasecmp(args.type, "audio")) - ast_rtp_get_peer(p->rtp, &sin); - else if (!strcasecmp(args.type, "video")) - ast_rtp_get_peer(p->vrtp, &sin); - else if (!strcasecmp(args.type, "text")) - ast_rtp_get_peer(p->trtp, &sin); + if (!strcasecmp(args.type, "audio")) { + stream = p->rtp; + } else if (!strcasecmp(args.type, "video")) { + stream = p->vrtp; + } else if (!strcasecmp(args.type, "text")) { + stream = p->trtp; + } + + if (!stream) { + return -1; + } + ast_rtp_get_peer(stream, &sin); snprintf(buf, buflen, "%s:%d", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port)); } else if (!strcasecmp(args.param, "rtpqos")) { struct ast_rtp_quality qos; |