提交 7c90deaa authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

RtpPacket::ParseExtensions(): improve alignment handling

上级 69a8a10d
...@@ -562,6 +562,13 @@ namespace RTC ...@@ -562,6 +562,13 @@ namespace RTC
uint8_t id = (*ptr & 0xF0) >> 4; uint8_t id = (*ptr & 0xF0) >> 4;
size_t len = static_cast<size_t>(*ptr & 0x0F) + 1; size_t len = static_cast<size_t>(*ptr & 0x0F) + 1;
// id=15 in One-Byte extensions means "stop parsing here".
if (id == 15u)
break;
// Valid extension id.
if (id != 0u)
{
if (ptr + 1 + len > extensionEnd) if (ptr + 1 + len > extensionEnd)
{ {
MS_WARN_TAG( MS_WARN_TAG(
...@@ -570,15 +577,16 @@ namespace RTC ...@@ -570,15 +577,16 @@ namespace RTC
break; break;
} }
// id=15 in One-Byte extensions means "stop parsing here". // Store the One-Byte extension element in a map.
if (id == 15u)
break;
// Store the One-Byte extension element in a map. Ignore if 0 (padding).
if (id != 0u)
this->oneByteExtensions[id] = reinterpret_cast<OneByteExtension*>(ptr); this->oneByteExtensions[id] = reinterpret_cast<OneByteExtension*>(ptr);
ptr += (1 + len); ptr += (1 + len);
}
// id=0 means alignment.
else
{
++ptr;
}
// Counting padding bytes. // Counting padding bytes.
while ((ptr < extensionEnd) && (*ptr == 0)) while ((ptr < extensionEnd) && (*ptr == 0))
...@@ -606,6 +614,9 @@ namespace RTC ...@@ -606,6 +614,9 @@ namespace RTC
uint8_t id = *ptr; uint8_t id = *ptr;
uint8_t len = *(ptr + 1); uint8_t len = *(ptr + 1);
// Valid extension id.
if (id != 0u)
{
if (ptr + 2 + len > extensionEnd) if (ptr + 2 + len > extensionEnd)
{ {
MS_WARN_TAG( MS_WARN_TAG(
...@@ -614,11 +625,16 @@ namespace RTC ...@@ -614,11 +625,16 @@ namespace RTC
break; break;
} }
// Store the Two-Bytes extension element in a map. Ignore if 0. // Store the Two-Bytes extension element in a map.
if (id != 0u)
this->twoBytesExtensions[id] = reinterpret_cast<TwoBytesExtension*>(ptr); this->twoBytesExtensions[id] = reinterpret_cast<TwoBytesExtension*>(ptr);
ptr += (2 + len); ptr += (2 + len);
}
// id=0 means alignment.
else
{
++ptr;
}
// Counting padding bytes. // Counting padding bytes.
while ((ptr < extensionEnd) && (*ptr == 0)) while ((ptr < extensionEnd) && (*ptr == 0))
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论