From e674e6ede9899986b378fc45880d77733378a626 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 30 Sep 2022 08:47:26 -0400 Subject: [PATCH] MT#55283 fix padding/SRTP order The packet must be decrypted first before RTP padding can be considered, as the padding count is part of the encrypted payload as well. Change-Id: I6aecff636efd420401856bb8110b3d784f989179 (cherry picked from commit 9e09cf3c40d56b55cbaa051f01b2bfe97fb0172b) --- daemon/media_socket.c | 4 ++-- lib/rtplib.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 06b41ee82..b51793693 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -1866,8 +1866,6 @@ static void media_packet_rtp_in(struct packet_handler_ctx *phc) bool unkern = false; if (G_LIKELY(!phc->rtcp && !rtp_payload(&phc->mp.rtp, &phc->mp.payload, &phc->s))) { - rtp_padding(phc->mp.rtp, &phc->mp.payload); - unkern = __stream_ssrc_in(phc->in_srtp, phc->mp.rtp->ssrc, &phc->mp.ssrc_in, phc->mp.media->monologue->ssrc_hash); @@ -2406,6 +2404,8 @@ static int stream_packet(struct packet_handler_ctx *phc) { if (handler_ret < 0) goto out; // receive error + rtp_padding(phc->mp.rtp, &phc->mp.payload); + // If recording pcap dumper is set, then we record the call. if (phc->mp.call->recording) dump_packet(&phc->mp, &phc->s); diff --git a/lib/rtplib.c b/lib/rtplib.c index 083c8331f..183b88ecc 100644 --- a/lib/rtplib.c +++ b/lib/rtplib.c @@ -107,6 +107,8 @@ error: int rtp_padding(struct rtp_header *header, str *payload) { + if (!header || payload->s) + return 0; if (!(header->v_p_x_cc & 0x20)) return 0; // no padding if (payload->len == 0)