]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix potential crashes from trying to reference non-existent RTP streams.
authorMark Michelson <mmichelson@digium.com>
Thu, 25 Mar 2010 17:10:59 +0000 (17:10 +0000)
committerMark Michelson <mmichelson@digium.com>
Thu, 25 Mar 2010 17:10:59 +0000 (17:10 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@254541 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 5fb2d22836add301442c6c27d2c116dff1f6ef28..b8fb00bc40a94d34c991c353a70cec1a98d4cd5d 100644 (file)
@@ -20023,19 +20023,26 @@ static int acf_channel_read(struct ast_channel *chan, const char *funcname, char
                ast_copy_string(buf, (p->t38.state == T38_DISABLED) ? "0" : "1", buflen);
        } else 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);
-               else
+               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;
+               } else {
+                       return -1;
+               }
+
+               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;