From b04115e23bf6335f38a91c8d20c5d5d6e4be2077 Mon Sep 17 00:00:00 2001 From: Dennis Yurasov Date: Mon, 2 Sep 2024 11:48:25 +0300 Subject: [PATCH] Do not kernelize rtp streams without confirmed SSRC --- daemon/media_socket.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 1a4604eada..3a65d61727 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -2143,7 +2143,7 @@ static void media_packet_rtp_in(struct packet_handler_ctx *phc) const char *unkern = NULL; - if (G_LIKELY(!phc->rtcp && !rtp_payload(&phc->mp.rtp, &phc->mp.payload, &phc->s))) { + if (G_LIKELY(!phc->rtcp && (phc->mp.rtp?1:!rtp_payload(&phc->mp.rtp, &phc->mp.payload, &phc->s)))) { unkern = __stream_ssrc_in(phc->in_srtp, phc->mp.rtp->ssrc, &phc->mp.ssrc_in, phc->mp.media->monologue->ssrc_hash); @@ -2315,6 +2315,19 @@ static bool media_packet_address_check(struct packet_handler_ctx *phc) "peer address confirmation purposes", FMT_M(endpoint_print_buf(&phc->mp.fsin))); goto out; + } else if(proto_is_rtp(phc->mp.media->protocol)) { + if(rtp_payload(&phc->mp.rtp, &phc->mp.payload, &phc->s) != 0) { + ilog(LOG_INFO | LOG_FLAG_LIMIT, "Ignoring invalid RTP packet from %s%s%s for " + "peer address confirmation purposes", + FMT_M(endpoint_print_buf(&phc->mp.fsin))); + goto out; + } + if(!phc->mp.rtp->ssrc) { + ilog(LOG_INFO | LOG_FLAG_LIMIT, "Ignoring RTP packet with zero SSRC from %s%s%s for " + "peer address confirmation purposes", + FMT_M(endpoint_print_buf(&phc->mp.fsin))); + goto out; + } } }