Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
fe0f7c40
Unverified
提交
fe0f7c40
authored
3月 26, 2024
作者:
Iñaki Baz Castillo
提交者:
GitHub
3月 26, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add fuzzer for RateCalculator class (#1358)
上级
8d757bc5
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
74 行增加
和
2 行删除
+74
-2
FuzzerRateCalculator.hpp
worker/fuzzer/include/RTC/FuzzerRateCalculator.hpp
+17
-0
FuzzerRateCalculator.cpp
worker/fuzzer/src/RTC/FuzzerRateCalculator.cpp
+47
-0
fuzzer.cpp
worker/fuzzer/src/fuzzer.cpp
+5
-1
meson.build
worker/meson.build
+1
-0
RateCalculator.cpp
worker/src/RTC/RateCalculator.cpp
+4
-1
没有找到文件。
worker/fuzzer/include/RTC/FuzzerRateCalculator.hpp
0 → 100644
浏览文件 @
fe0f7c40
#ifndef MS_FUZZER_RTC_RATE_CALCULATOR_HPP
#define MS_FUZZER_RTC_RATE_CALCULATOR_HPP
#include "common.hpp"
namespace
Fuzzer
{
namespace
RTC
{
namespace
RateCalculator
{
void
Fuzz
(
const
uint8_t
*
data
,
size_t
len
);
}
}
// namespace RTC
}
// namespace Fuzzer
#endif
worker/fuzzer/src/RTC/FuzzerRateCalculator.cpp
0 → 100644
浏览文件 @
fe0f7c40
#include "RTC/FuzzerRateCalculator.hpp"
#include "DepLibUV.hpp"
#include "Utils.hpp"
#include "RTC/RateCalculator.hpp"
#include "RTC/RtpPacket.hpp" // RTC::MtuSize
static
::
RTC
::
RateCalculator
rateCalculator
;
static
uint64_t
nowMs
;
// This Init() function must be declared static, otherwise linking will fail if
// another source file defines same non static Init() function.
static
int
Init
();
void
Fuzzer
::
RTC
::
RateCalculator
::
Fuzz
(
const
uint8_t
*
data
,
size_t
len
)
{
// Trick to initialize our stuff just once.
static
int
unused
=
Init
();
// Avoid [-Wunused-variable].
unused
++
;
// We need at least 2 bytes of |data|.
if
(
len
<
2
)
{
return
;
}
auto
size
=
static_cast
<
size_t
>
(
Utils
::
Crypto
::
GetRandomUInt
(
0u
,
static_cast
<
uint32_t
>
(
::
RTC
::
MtuSize
)));
nowMs
+=
Utils
::
Crypto
::
GetRandomUInt
(
0u
,
1000u
);
rateCalculator
.
Update
(
size
,
nowMs
);
// Only get rate from time to time.
if
(
Utils
::
Byte
::
Get2Bytes
(
data
,
0
)
%
100
==
0
)
{
rateCalculator
.
GetRate
(
nowMs
);
}
}
int
Init
()
{
nowMs
=
DepLibUV
::
GetTimeMs
();
return
0
;
}
worker/fuzzer/src/fuzzer.cpp
浏览文件 @
fe0f7c40
...
...
@@ -16,6 +16,7 @@
#include "RTC/Codecs/FuzzerVP9.hpp"
#include "RTC/DtlsTransport.hpp"
#include "RTC/FuzzerDtlsTransport.hpp"
#include "RTC/FuzzerRateCalculator.hpp"
#include "RTC/FuzzerRtpPacket.hpp"
#include "RTC/FuzzerRtpRetransmissionBuffer.hpp"
#include "RTC/FuzzerRtpStreamSend.hpp"
...
...
@@ -35,7 +36,9 @@ bool fuzzRtcp = false;
bool
fuzzCodecs
=
false
;
bool
fuzzUtils
=
false
;
int
Init
();
// This Init() function must be declared static, otherwise linking will fail if
// another source file defines same non static Init() function.
static
int
Init
();
extern
"C"
int
LLVMFuzzerTestOneInput
(
const
uint8_t
*
data
,
size_t
len
)
{
...
...
@@ -61,6 +64,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t len)
Fuzzer
::
RTC
::
RtpStreamSend
::
Fuzz
(
data
,
len
);
Fuzzer
::
RTC
::
RtpRetransmissionBuffer
::
Fuzz
(
data
,
len
);
Fuzzer
::
RTC
::
SeqManager
::
Fuzz
(
data
,
len
);
Fuzzer
::
RTC
::
RateCalculator
::
Fuzz
(
data
,
len
);
}
if
(
fuzzRtcp
)
...
...
worker/meson.build
浏览文件 @
fe0f7c40
...
...
@@ -432,6 +432,7 @@ executable(
'fuzzer/src/fuzzer.cpp',
'fuzzer/src/FuzzerUtils.cpp',
'fuzzer/src/RTC/FuzzerDtlsTransport.cpp',
'fuzzer/src/RTC/FuzzerRateCalculator.cpp',
'fuzzer/src/RTC/FuzzerRtpPacket.cpp',
'fuzzer/src/RTC/FuzzerRtpRetransmissionBuffer.cpp',
'fuzzer/src/RTC/FuzzerRtpStreamSend.cpp',
...
...
worker/src/RTC/RateCalculator.cpp
浏览文件 @
fe0f7c40
...
...
@@ -36,7 +36,10 @@ namespace RTC
MS_ASSERT
(
this
->
newestItemIndex
!=
this
->
oldestItemIndex
||
this
->
oldestItemIndex
==
-
1
,
"newest index overlaps with the oldest one"
);
"newest index overlaps with the oldest one [newestItemIndex:%"
PRId32
", oldestItemIndex:%"
PRId32
"]"
,
this
->
newestItemIndex
,
this
->
oldestItemIndex
);
// Set the newest item.
BufferItem
&
item
=
this
->
buffer
[
this
->
newestItemIndex
];
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论