Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
10cfd3af
Unverified
提交
10cfd3af
authored
7月 28, 2022
作者:
José Luis Millán
提交者:
GitHub
7月 28, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
RtpStreamSend: Do not store too old RTP packets (#885)
RtpStreamSend: Do not store too old RTP packets
上级
a0888b9c
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
131 行增加
和
25 行删除
+131
-25
Makefile
worker/Makefile
+1
-1
FuzzerRtpStreamSend.hpp
worker/fuzzer/include/RTC/FuzzerRtpStreamSend.hpp
+17
-0
crash-92e8ac42827b4da15e94289879d56a44c70ee4ec
...er/reports/crash-92e8ac42827b4da15e94289879d56a44c70ee4ec
+0
-0
FuzzerRtpStreamSend.cpp
worker/fuzzer/src/RTC/FuzzerRtpStreamSend.cpp
+64
-0
fuzzer.cpp
worker/fuzzer/src/fuzzer.cpp
+21
-9
meson.build
worker/meson.build
+1
-0
RtpPacket.cpp
worker/src/RTC/RtpPacket.cpp
+1
-4
RtpStreamSend.cpp
worker/src/RTC/RtpStreamSend.cpp
+26
-11
没有找到文件。
worker/Makefile
浏览文件 @
10cfd3af
...
@@ -206,7 +206,7 @@ fuzzer: setup
...
@@ -206,7 +206,7 @@ fuzzer: setup
$(MESON)
install
-C
$(BUILD_DIR)
--no-rebuild
--tags
mediasoup-worker-fuzzer
$(MESON)
install
-C
$(BUILD_DIR)
--no-rebuild
--tags
mediasoup-worker-fuzzer
fuzzer-run-all
:
fuzzer-run-all
:
LSAN_OPTIONS
=
verbosity
=
1:log_threads
=
1
./
$(BUILD_DIR)
/mediasoup-worker-fuzzer
-artifact_prefix
=
fuzzer/reports/
-max_len
=
1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus
LSAN_OPTIONS
=
verbosity
=
1:log_threads
=
1
$(BUILD_DIR)
/mediasoup-worker-fuzzer
-artifact_prefix
=
fuzzer/reports/
-max_len
=
1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus
docker-build
:
docker-build
:
ifeq
($(DOCKER_NO_CACHE),true)
ifeq
($(DOCKER_NO_CACHE),true)
...
...
worker/fuzzer/include/RTC/FuzzerRtpStreamSend.hpp
0 → 100644
浏览文件 @
10cfd3af
#ifndef MS_FUZZER_RTC_RTP_STREAM_SEND_HPP
#define MS_FUZZER_RTC_RTP_STREAM_SEND_HPP
#include "common.hpp"
namespace
Fuzzer
{
namespace
RTC
{
namespace
RtpStreamSend
{
void
Fuzz
(
const
uint8_t
*
data
,
size_t
len
);
}
}
// namespace RTC
}
// namespace Fuzzer
#endif
worker/fuzzer/reports/crash-92e8ac42827b4da15e94289879d56a44c70ee4ec
0 → 100644
浏览文件 @
10cfd3af
File added
worker/fuzzer/src/RTC/FuzzerRtpStreamSend.cpp
0 → 100644
浏览文件 @
10cfd3af
#include "RTC/FuzzerRtpStreamSend.hpp"
#include "Utils.hpp"
#include "RTC/RtpStreamSend.hpp"
class
TestRtpStreamListener
:
public
RTC
::
RtpStreamSend
::
Listener
{
public
:
void
OnRtpStreamScore
(
RTC
::
RtpStream
*
/*rtpStream*/
,
uint8_t
/*score*/
,
uint8_t
/*previousScore*/
)
override
{
}
void
OnRtpStreamRetransmitRtpPacket
(
RTC
::
RtpStreamSend
*
/*rtpStream*/
,
RTC
::
RtpPacket
*
packet
)
override
{
}
};
void
Fuzzer
::
RTC
::
RtpStreamSend
::
Fuzz
(
const
uint8_t
*
data
,
size_t
len
)
{
// clang-format off
uint8_t
buffer
[]
=
{
0
b10000000
,
0
b01111011
,
0
b01010010
,
0
b00001110
,
0
b01011011
,
0
b01101011
,
0
b11001010
,
0
b10110101
,
0
,
0
,
0
,
2
};
// clang-format on
// Create base RtpPacket instance.
auto
*
packet
=
::
RTC
::
RtpPacket
::
Parse
(
buffer
,
12
);
size_t
offset
{
0u
};
// Create a RtpStreamSend instance.
TestRtpStreamListener
testRtpStreamListener
;
// Create RtpStreamSend instance.
::
RTC
::
RtpStream
::
Params
params
;
params
.
ssrc
=
1111
;
params
.
clockRate
=
90000
;
params
.
useNack
=
true
;
params
.
mimeType
.
type
=
::
RTC
::
RtpCodecMimeType
::
Type
::
VIDEO
;
packet
->
SetSsrc
(
params
.
ssrc
);
std
::
string
mid
;
::
RTC
::
RtpStreamSend
*
stream
=
new
::
RTC
::
RtpStreamSend
(
&
testRtpStreamListener
,
params
,
mid
);
while
(
len
>=
4u
)
{
std
::
shared_ptr
<::
RTC
::
RtpPacket
>
sharedPacket
;
// Set 'random' sequence number and timestamp.
packet
->
SetSequenceNumber
(
Utils
::
Byte
::
Get2Bytes
(
data
,
offset
));
packet
->
SetTimestamp
(
Utils
::
Byte
::
Get4Bytes
(
data
,
offset
));
stream
->
ReceivePacket
(
packet
,
sharedPacket
);
len
-=
4u
;
offset
+=
4
;
}
delete
stream
;
delete
packet
;
}
worker/fuzzer/src/fuzzer.cpp
浏览文件 @
10cfd3af
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include "Settings.hpp"
#include "Settings.hpp"
#include "Utils.hpp"
#include "Utils.hpp"
#include "RTC/FuzzerRtpPacket.hpp"
#include "RTC/FuzzerRtpPacket.hpp"
#include "RTC/FuzzerRtpStreamSend.hpp"
#include "RTC/FuzzerStunPacket.hpp"
#include "RTC/FuzzerStunPacket.hpp"
#include "RTC/FuzzerTrendCalculator.hpp"
#include "RTC/FuzzerTrendCalculator.hpp"
#include "RTC/RTCP/FuzzerPacket.hpp"
#include "RTC/RTCP/FuzzerPacket.hpp"
...
@@ -18,10 +19,11 @@
...
@@ -18,10 +19,11 @@
#include <stddef.h>
#include <stddef.h>
#include <stdint.h>
#include <stdint.h>
bool
fuzzStun
=
false
;
bool
fuzzStun
=
false
;
bool
fuzzRtp
=
false
;
bool
fuzzRtp
=
false
;
bool
fuzzRtcp
=
false
;
bool
fuzzRtcp
=
false
;
bool
fuzzUtils
=
false
;
bool
fuzzRtpStream
=
false
;
bool
fuzzUtils
=
false
;
int
Init
();
int
Init
();
...
@@ -42,6 +44,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t len)
...
@@ -42,6 +44,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t len)
if
(
fuzzRtcp
)
if
(
fuzzRtcp
)
Fuzzer
::
RTC
::
RTCP
::
Packet
::
Fuzz
(
data
,
len
);
Fuzzer
::
RTC
::
RTCP
::
Packet
::
Fuzz
(
data
,
len
);
if
(
fuzzRtpStream
)
Fuzzer
::
RTC
::
RtpStreamSend
::
Fuzz
(
data
,
len
);
if
(
fuzzUtils
)
if
(
fuzzUtils
)
{
{
Fuzzer
::
Utils
::
Fuzz
(
data
,
len
);
Fuzzer
::
Utils
::
Fuzz
(
data
,
len
);
...
@@ -85,20 +90,27 @@ int Init()
...
@@ -85,20 +90,27 @@ int Init()
fuzzRtcp
=
true
;
fuzzRtcp
=
true
;
}
}
if
(
std
::
getenv
(
"MS_FUZZ_RTP_STREAM"
)
&&
std
::
string
(
std
::
getenv
(
"MS_FUZZ_RTP_STREAM"
))
==
"1"
)
{
std
::
cout
<<
"[fuzzer] RTP Stream fuzzers enabled"
<<
std
::
endl
;
fuzzRtpStream
=
true
;
}
if
(
std
::
getenv
(
"MS_FUZZ_UTILS"
)
&&
std
::
string
(
std
::
getenv
(
"MS_FUZZ_UTILS"
))
==
"1"
)
if
(
std
::
getenv
(
"MS_FUZZ_UTILS"
)
&&
std
::
string
(
std
::
getenv
(
"MS_FUZZ_UTILS"
))
==
"1"
)
{
{
std
::
cout
<<
"[fuzzer] Utils fuzzers enabled"
<<
std
::
endl
;
std
::
cout
<<
"[fuzzer] Utils fuzzers enabled"
<<
std
::
endl
;
fuzzUtils
=
true
;
fuzzUtils
=
true
;
}
}
if
(
!
fuzzUtils
&&
!
fuzzStun
&&
!
fuzzRtcp
&&
!
fuzzRtp
)
if
(
!
fuzzUtils
&&
!
fuzzStun
&&
!
fuzzRtcp
&&
!
fuzzRtp
&&
!
fuzzRtpStream
)
{
{
std
::
cout
<<
"[fuzzer] all fuzzers enabled"
<<
std
::
endl
;
std
::
cout
<<
"[fuzzer] all fuzzers enabled"
<<
std
::
endl
;
fuzzStun
=
true
;
fuzzStun
=
true
;
fuzzRtp
=
true
;
fuzzRtp
=
true
;
fuzzRtcp
=
true
;
fuzzRtcp
=
true
;
fuzzUtils
=
true
;
fuzzRtpStream
=
true
;
fuzzUtils
=
true
;
}
}
Settings
::
configuration
.
logLevel
=
logLevel
;
Settings
::
configuration
.
logLevel
=
logLevel
;
...
...
worker/meson.build
浏览文件 @
10cfd3af
...
@@ -348,6 +348,7 @@ if host_machine.system() == 'linux'
...
@@ -348,6 +348,7 @@ if host_machine.system() == 'linux'
'fuzzer/src/FuzzerUtils.cpp',
'fuzzer/src/FuzzerUtils.cpp',
'fuzzer/src/RTC/FuzzerStunPacket.cpp',
'fuzzer/src/RTC/FuzzerStunPacket.cpp',
'fuzzer/src/RTC/FuzzerRtpPacket.cpp',
'fuzzer/src/RTC/FuzzerRtpPacket.cpp',
'fuzzer/src/RTC/FuzzerRtpStreamSend.cpp',
'fuzzer/src/RTC/FuzzerTrendCalculator.cpp',
'fuzzer/src/RTC/FuzzerTrendCalculator.cpp',
'fuzzer/src/RTC/RTCP/FuzzerBye.cpp',
'fuzzer/src/RTC/RTCP/FuzzerBye.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackPs.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackPs.cpp',
...
...
worker/src/RTC/RtpPacket.cpp
浏览文件 @
10cfd3af
...
@@ -117,10 +117,7 @@ namespace RTC
...
@@ -117,10 +117,7 @@ namespace RTC
payloadLength
+
size_t
{
payloadPadding
},
payloadLength
+
size_t
{
payloadPadding
},
"packet's computed size does not match received size"
);
"packet's computed size does not match received size"
);
auto
*
packet
=
return
new
RtpPacket
(
header
,
headerExtension
,
payload
,
payloadLength
,
payloadPadding
,
len
);
new
RtpPacket
(
header
,
headerExtension
,
payload
,
payloadLength
,
payloadPadding
,
len
);
return
packet
;
}
}
/* Instance methods. */
/* Instance methods. */
...
...
worker/src/RTC/RtpStreamSend.cpp
浏览文件 @
10cfd3af
...
@@ -38,7 +38,12 @@ namespace RTC
...
@@ -38,7 +38,12 @@ namespace RTC
RtpStreamSend
::
StorageItem
*
RtpStreamSend
::
StorageItemBuffer
::
GetFirst
()
const
RtpStreamSend
::
StorageItem
*
RtpStreamSend
::
StorageItemBuffer
::
GetFirst
()
const
{
{
return
this
->
Get
(
this
->
startSeq
);
auto
*
storageItem
=
this
->
Get
(
this
->
startSeq
);
MS_ASSERT
(
storageItem
,
"first storage item is missing"
);
MS_ASSERT
(
storageItem
->
packet
,
"storage item does not contain original packet"
);
return
storageItem
;
}
}
RtpStreamSend
::
StorageItem
*
RtpStreamSend
::
StorageItemBuffer
::
Get
(
uint16_t
seq
)
const
RtpStreamSend
::
StorageItem
*
RtpStreamSend
::
StorageItemBuffer
::
Get
(
uint16_t
seq
)
const
...
@@ -452,6 +457,22 @@ namespace RTC
...
@@ -452,6 +457,22 @@ namespace RTC
return
;
return
;
}
}
// Check if RTP packet is too old to be stored.
if
(
this
->
storageItemBuffer
.
GetBufferSize
()
>
0
)
{
auto
*
storageItem
=
this
->
storageItemBuffer
.
GetFirst
();
// Processing RTP packet is older than first one.
if
(
RTC
::
SeqManager
<
uint32_t
>::
IsSeqLowerThan
(
packet
->
GetTimestamp
(),
storageItem
->
timestamp
))
{
uint32_t
diffTs
{
storageItem
->
timestamp
-
packet
->
GetTimestamp
()
};
// RTP packet is older than the retransmission buffer size.
if
(
static_cast
<
uint32_t
>
(
diffTs
*
1000
/
this
->
params
.
clockRate
)
>=
this
->
retransmissionBufferSize
)
return
;
}
}
this
->
ClearOldPackets
(
packet
);
this
->
ClearOldPackets
(
packet
);
auto
seq
=
packet
->
GetSequenceNumber
();
auto
seq
=
packet
->
GetSequenceNumber
();
...
@@ -493,7 +514,6 @@ namespace RTC
...
@@ -493,7 +514,6 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
auto
packetTs
{
packet
->
GetTimestamp
()
};
auto
clockRate
{
this
->
params
.
clockRate
};
auto
clockRate
{
this
->
params
.
clockRate
};
const
auto
bufferSize
=
this
->
storageItemBuffer
.
GetBufferSize
();
const
auto
bufferSize
=
this
->
storageItemBuffer
.
GetBufferSize
();
...
@@ -502,16 +522,11 @@ namespace RTC
...
@@ -502,16 +522,11 @@ namespace RTC
// items that contain packets older than `MaxRetransmissionDelay`.
// items that contain packets older than `MaxRetransmissionDelay`.
for
(
size_t
i
{
0
};
i
<
bufferSize
&&
this
->
storageItemBuffer
.
GetBufferSize
()
!=
0
;
++
i
)
for
(
size_t
i
{
0
};
i
<
bufferSize
&&
this
->
storageItemBuffer
.
GetBufferSize
()
!=
0
;
++
i
)
{
{
auto
*
firstStorageItem
=
this
->
storageItemBuffer
.
GetFirst
();
auto
*
storageItem
=
this
->
storageItemBuffer
.
GetFirst
();
uint32_t
diffTs
{
packet
->
GetTimestamp
()
-
storageItem
->
timestamp
};
MS_ASSERT
(
firstStorageItem
,
"first storage item is missing"
);
MS_ASSERT
(
firstStorageItem
->
packet
,
"storage item does not contain original packet"
);
auto
firstPacketTs
{
firstStorageItem
->
timestamp
};
uint32_t
diffTs
{
packetTs
-
firstPacketTs
};
//
RTP packet is older than first RTP packet
.
//
Processing RTP packet is older than first one
.
if
(
RTC
::
SeqManager
<
uint32_t
>::
IsSeqLowerThan
(
packet
Ts
,
firstPacketTs
))
if
(
RTC
::
SeqManager
<
uint32_t
>::
IsSeqLowerThan
(
packet
->
GetTimestamp
(),
storageItem
->
timestamp
))
break
;
break
;
// First RTP packet is recent enough.
// First RTP packet is recent enough.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论