Skip to content

Commit 1080fa9

Browse files
Fix RTP header extension length calculation (RFC 3550 compliance) (#1556)
* Fix RTP header extension length calculation (RFC 3550 compliance) - The extension length field specifies the number of 32-bit words, not bytes - Multiply the length field by 4 to convert from 32-bit words to bytes * Review suggestion: fix for misleading variable name Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 415e3f3 commit 1080fa9

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/SIPSorcery/net/DtlsSrtp/Lib/SRTP/Readers/RtpReader.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,10 @@ public static int ReadExtensionsLength(ReadOnlySpan<byte> payload)
4545
int length = ReadHeaderLenWithoutExtensions(payload);
4646
if ((payload[0] & 0x10) == 0x10)
4747
{
48-
return 4 + System.Buffers.Binary.BinaryPrimitives.ReadUInt16BigEndian(payload.Slice(length + 2, 2));
49-
}
50-
else
51-
{
52-
return 0;
48+
var extensionLengthWords = System.Buffers.Binary.BinaryPrimitives.ReadUInt16BigEndian(payload.Slice(length + 2, 2));
49+
return 4 + (extensionLengthWords * 4);
5350
}
51+
return 0;
5452
}
5553

5654
public static int ReadHeaderLenWithoutExtensions(ReadOnlySpan<byte> payload)

0 commit comments

Comments
 (0)