diff --git a/src/Http/HttpRequestSplitter.cpp b/src/Http/HttpRequestSplitter.cpp index 6b4c0123..70a713e6 100644 --- a/src/Http/HttpRequestSplitter.cpp +++ b/src/Http/HttpRequestSplitter.cpp @@ -13,9 +13,16 @@ #include "Util/util.h" using namespace toolkit; +//协议解析最大缓存1兆数据 +static constexpr size_t kMaxCacheSize = 1 * 1024 * 1024; + namespace mediakit { void HttpRequestSplitter::input(const char *data,size_t len) { + if (remainDataSize() > kMaxCacheSize) { + //缓存太多数据无法处理则上抛异常 + throw std::out_of_range("remain data size is too huge:" + to_string(remainDataSize())); + } const char *ptr = data; if(!_remain_data.empty()){ _remain_data.append(data,len); diff --git a/src/Rtp/PSDecoder.cpp b/src/Rtp/PSDecoder.cpp index 448f1809..6da45104 100644 --- a/src/Rtp/PSDecoder.cpp +++ b/src/Rtp/PSDecoder.cpp @@ -71,11 +71,6 @@ const char *PSDecoder::onSearchPacketTail(const char *data, size_t len) { InfoL << "解析 ps 异常: bytes=" << len << ", exception=" << ex.what() << ", hex=" << hexdump(data, MIN(len, 32)); - if (remainDataSize() > 256 * 1024) { - //缓存太多数据无法处理则上抛异常 - throw; - } - return nullptr; } }