Skip to content

Commit 0472df2

Browse files
committed
fix: rtcp_xr_unpack death-loop
1 parent b72e645 commit 0472df2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

librtp/source/rtcp-xr.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ static int rtcp_xr_ecn_pack(const rtcp_ecn_t* ecn, uint8_t* ptr, uint32_t bytes)
581581
void rtcp_xr_unpack(struct rtp_context* ctx, const rtcp_header_t* header, const uint8_t* ptr, size_t bytes)
582582
{
583583
int r;
584+
size_t len;
584585
struct rtcp_msg_t msg;
585586
struct rtp_member* sender;
586587

@@ -600,8 +601,11 @@ void rtcp_xr_unpack(struct rtp_context* ctx, const rtcp_header_t* header, const
600601
bytes -= 4;
601602
while (bytes >= 4)
602603
{
603-
msg.type = RTCP_XR | (ptr[0] << 8);
604+
len = nbo_r16(ptr + 2);
605+
if (len * 4 > bytes - 4)
606+
break; // invalid
604607

608+
msg.type = RTCP_XR | (ptr[0] << 8);
605609
switch (ptr[0])
606610
{
607611
case RTCP_XR_LRLE:
@@ -633,6 +637,9 @@ void rtcp_xr_unpack(struct rtp_context* ctx, const rtcp_header_t* header, const
633637
r = 0; // ignore
634638
break;
635639
}
640+
641+
ptr += len;
642+
bytes -= len;
636643
}
637644

638645
return;

0 commit comments

Comments
 (0)