降低TCP RTP 2字节头被误判为EHOME头的风险 (#2502)

当TCP RTP包大小为256字节时,可能触发RtpSplitter::onSearchPacketTail误判为EHOME格式。
这个修改一旦检测到数据不是EHOME格式,则后续不再进行尝试,以减小误判的风险。
This commit is contained in:
dengjfzh 2023-05-27 22:27:10 +08:00 committed by GitHub
parent 032a2ac91d
commit 18dbbc8d19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View File

@ -46,17 +46,20 @@ const char *RtpSplitter::onSearchPacketTail(const char *data, size_t len) {
return nullptr; return nullptr;
} }
if (isEhome(data, len)) { if ( _is_ehome ) {
//是ehome协议 if (isEhome(data, len)) {
if (len < kEHOME_OFFSET + 4) { //是ehome协议
//数据不够 if (len < kEHOME_OFFSET + 4) {
return nullptr; //数据不够
return nullptr;
}
//忽略ehome私有头后是rtsp样式的rtp多4个字节
_offset = kEHOME_OFFSET + 4;
_is_ehome = true;
//忽略ehome私有头
return onSearchPacketTail_l(data + kEHOME_OFFSET + 2, len - kEHOME_OFFSET - 2);
} }
//忽略ehome私有头后是rtsp样式的rtp多4个字节 _is_ehome = false;
_offset = kEHOME_OFFSET + 4;
_is_ehome = true;
//忽略ehome私有头
return onSearchPacketTail_l(data + kEHOME_OFFSET + 2, len - kEHOME_OFFSET - 2);
} }
if ( _is_rtsp_interleaved ) { if ( _is_rtsp_interleaved ) {

View File

@ -35,7 +35,7 @@ protected:
const char *onSearchPacketTail_l(const char *data, size_t len); const char *onSearchPacketTail_l(const char *data, size_t len);
private: private:
bool _is_ehome = false; bool _is_ehome = true;
bool _is_rtsp_interleaved = true; bool _is_rtsp_interleaved = true;
size_t _offset = 0; size_t _offset = 0;
}; };