From cbfa8a575033dc0f1fb3cbb14f3be66c5a4ec469 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 39899ca2f..13e11d43a 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -1476,8 +1476,6 @@ static void media_packet_rtp(struct packet_handler_ctx *phc) return; if (G_LIKELY(!phc->rtcp && !rtp_payload(&phc->mp.rtp, &phc->mp.payload, &phc->s))) { - rtp_padding(phc->mp.rtp, &phc->mp.payload); - if (G_LIKELY(phc->out_srtp != NULL)) __stream_ssrc(phc->in_srtp, phc->out_srtp, phc->mp.rtp->ssrc, &phc->mp.ssrc_in, &phc->mp.ssrc_out, phc->mp.call->ssrc_hash, phc); @@ -1905,6 +1903,8 @@ static int stream_packet(struct packet_handler_ctx *phc) { handler_ret = media_packet_decrypt(phc); + 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 1c5c6dec6..e592170bd 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)