diff --git a/srtp/srtp.c b/srtp/srtp.c index c47830b2a..4b1340ae1 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -2137,7 +2137,7 @@ srtp_err_status_t srtp_protect_mki(srtp_ctx_t *ctx, */ stream = srtp_get_stream(ctx, hdr->ssrc); if (stream == NULL) { - if (ctx->stream_template != NULL) { + if ((ctx->stream_template != NULL) && (ctx->stream_template->direction != dir_srtp_receiver)) { srtp_stream_ctx_t *new_stream; /* allocate and initialize a new stream */ @@ -2465,6 +2465,10 @@ srtp_err_status_t srtp_unprotect_mki(srtp_ctx_t *ctx, stream = srtp_get_stream(ctx, hdr->ssrc); if (stream == NULL) { if (ctx->stream_template != NULL) { + if (ctx->stream_template->direction == dir_srtp_sender) { + return srtp_err_status_no_ctx; + } + stream = ctx->stream_template; debug_print(mod_srtp, "using provisional stream (SSRC: 0x%08x)", ntohl(hdr->ssrc));