summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2018-02-21 10:38:49 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2018-02-21 10:38:49 -0600
commit86c75af8600464e6f8aa326ba89006410ac0dd6e (patch)
tree5faeeb089176f472ef9f438edbfff6d8b66f7df8
parentd424850d58a90b1640d7b3d94490eea5535637ee (diff)
parente70c4ec84d3553f0a979fdd5a7ca6fc1da15eabd (diff)
Merge "AST-2018-001: rtp / channel: Don't allow an unnegotiated format to be passed up."
-rw-r--r--main/channel.c19
-rw-r--r--main/rtp_engine.c2
2 files changed, 18 insertions, 3 deletions
diff --git a/main/channel.c b/main/channel.c
index fc89d67cb..c71d19b81 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -3667,7 +3667,17 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio, int
* originated from and update the frame to include it.
*/
stream = default_stream = ast_channel_get_default_stream(chan, ast_format_get_type(f->subclass.format));
- f->stream_num = ast_stream_get_position(stream);
+ /* In order to allow media to be passed up the underlying media type has to have a format negotiated on
+ * the channel itself. In cases where this hasn't happened the channel driver is incorrectly passing up
+ * a frame for a format that has not been negotiated. If this occurs just drop the frame as we have no
+ * stream that it came from.
+ */
+ if (!stream) {
+ ast_frfree(f);
+ f = &ast_null_frame;
+ } else {
+ f->stream_num = ast_stream_get_position(stream);
+ }
}
}
} else {
@@ -3700,7 +3710,12 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio, int
*/
if (f && (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO)) {
stream = default_stream = ast_channel_get_default_stream(chan, ast_format_get_type(f->subclass.format));
- f->stream_num = ast_stream_get_position(stream);
+ if (!stream) {
+ ast_frfree(f);
+ f = &ast_null_frame;
+ } else {
+ f->stream_num = ast_stream_get_position(stream);
+ }
}
}
else
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index f108a703b..627605a1a 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -1216,7 +1216,7 @@ struct ast_rtp_payload_type *ast_rtp_codecs_get_payload(struct ast_rtp_codecs *c
}
ast_rwlock_unlock(&codecs->codecs_lock);
- if (!type) {
+ if (!type && payload <= AST_RTP_PT_LAST_STATIC) {
ast_rwlock_rdlock(&static_RTP_PT_lock);
type = ao2_bump(static_RTP_PT[payload]);
ast_rwlock_unlock(&static_RTP_PT_lock);