提交 46ae2eaf authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

RtpPacket: Fix Two-Byte header extensions parsing

上级 5b6cad15
...@@ -67,13 +67,8 @@ namespace RTC ...@@ -67,13 +67,8 @@ namespace RTC
/* Struct for Two-Bytes extension. */ /* Struct for Two-Bytes extension. */
struct TwoBytesExtension struct TwoBytesExtension
{ {
#if defined(MS_LITTLE_ENDIAN)
uint8_t len : 8;
uint8_t id : 8;
#elif defined(MS_BIG_ENDIAN)
uint8_t id : 8; uint8_t id : 8;
uint8_t len : 8; uint8_t len : 8;
#endif
uint8_t value[1]; uint8_t value[1];
}; };
......
...@@ -547,7 +547,7 @@ namespace RTC ...@@ -547,7 +547,7 @@ namespace RTC
if (id != 0u) if (id != 0u)
this->oneByteExtensions[id] = reinterpret_cast<OneByteExtension*>(ptr); this->oneByteExtensions[id] = reinterpret_cast<OneByteExtension*>(ptr);
ptr += 1 + len; ptr += (1 + len);
// Counting padding bytes. // Counting padding bytes.
while ((ptr < extensionEnd) && (*ptr == 0)) while ((ptr < extensionEnd) && (*ptr == 0))
...@@ -564,12 +564,16 @@ namespace RTC ...@@ -564,12 +564,16 @@ namespace RTC
uint8_t* extensionEnd = extensionStart + GetExtensionHeaderLength(); uint8_t* extensionEnd = extensionStart + GetExtensionHeaderLength();
uint8_t* ptr = extensionStart; uint8_t* ptr = extensionStart;
// ptr points to the ID field (1 byte).
// ptr+1 points to the length field (1 byte, can have value 0).
// Two-Byte extensions can have length 0.
while (ptr + 1 < extensionEnd) while (ptr + 1 < extensionEnd)
{ {
uint8_t id = *ptr; uint8_t id = *ptr;
size_t len = *(++ptr); uint8_t len = *(ptr + 1);
if (ptr + len > extensionEnd) if (ptr + 2 + len > extensionEnd)
{ {
MS_WARN_TAG( MS_WARN_TAG(
rtp, "not enough space for the announced Two-Bytes header extension element value"); rtp, "not enough space for the announced Two-Bytes header extension element value");
...@@ -581,7 +585,7 @@ namespace RTC ...@@ -581,7 +585,7 @@ namespace RTC
if (id != 0u) if (id != 0u)
this->twoBytesExtensions[id] = reinterpret_cast<TwoBytesExtension*>(ptr); this->twoBytesExtensions[id] = reinterpret_cast<TwoBytesExtension*>(ptr);
ptr += len; ptr += (2 + len);
// Counting padding bytes. // Counting padding bytes.
while ((ptr < extensionEnd) && (*ptr == 0)) while ((ptr < extensionEnd) && (*ptr == 0))
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论