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

RtpPacket::ParseExtensions(): improve alignment handling

上级 69a8a10d
...@@ -562,23 +562,31 @@ namespace RTC ...@@ -562,23 +562,31 @@ 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;
if (ptr + 1 + len > extensionEnd)
{
MS_WARN_TAG(
rtp, "not enough space for the announced One-Byte header extension element value");
break;
}
// id=15 in One-Byte extensions means "stop parsing here". // id=15 in One-Byte extensions means "stop parsing here".
if (id == 15u) if (id == 15u)
break; break;
// Store the One-Byte extension element in a map. Ignore if 0 (padding). // Valid extension id.
if (id != 0u) if (id != 0u)
{
if (ptr + 1 + len > extensionEnd)
{
MS_WARN_TAG(
rtp, "not enough space for the announced One-Byte header extension element value");
break;
}
// Store the One-Byte extension element in a map.
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,19 +614,27 @@ namespace RTC ...@@ -606,19 +614,27 @@ namespace RTC
uint8_t id = *ptr; uint8_t id = *ptr;
uint8_t len = *(ptr + 1); uint8_t len = *(ptr + 1);
if (ptr + 2 + len > extensionEnd) // Valid extension id.
if (id != 0u)
{ {
MS_WARN_TAG( if (ptr + 2 + len > extensionEnd)
rtp, "not enough space for the announced Two-Bytes header extension element value"); {
MS_WARN_TAG(
rtp, "not enough space for the announced Two-Bytes header extension element value");
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 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论