From af72548a43d7a65ed7d4a0c15eaea0d95526a9a8 Mon Sep 17 00:00:00 2001 From: Alex X Date: Mon, 13 Nov 2023 21:56:35 +0300 Subject: [PATCH] Fix panic for broken RTP with AAC #697 --- pkg/aac/rtp.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/aac/rtp.go b/pkg/aac/rtp.go index a59a0d67..b5ae4a10 100644 --- a/pkg/aac/rtp.go +++ b/pkg/aac/rtp.go @@ -28,9 +28,13 @@ func RTPDepay(handler core.HandlerFunc) core.HandlerFunc { headers := packet.Payload[2 : 2+headersSize] units := packet.Payload[2+headersSize:] - for len(headers) > 0 { + for len(headers) >= 2 { unitSize := binary.BigEndian.Uint16(headers) >> 3 + if len(units) < int(unitSize) { + return + } + unit := units[:unitSize] headers = headers[2:]