From 7736c30033eaf9b4399f46be6b7b81c4fef16d22 Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Mon, 21 Nov 2022 11:46:50 -0500 Subject: [PATCH] Respect the direction set in a template stream --- srtp/srtp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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));