分包逻辑添加边界检测代码

This commit is contained in:
xia-chu 2021-02-21 22:24:46 +08:00
parent ef46945de6
commit 8d50d3c397

View File

@ -39,9 +39,12 @@ void HttpRequestSplitter::input(const char *data,size_t len) {
const char *index = nullptr;
_remain_data_size = len;
while (_content_len == 0 && _remain_data_size > 0 && (index = onSearchPacketTail(ptr,_remain_data_size)) != nullptr) {
if(index == ptr){
if (index == ptr) {
break;
}
if (index < ptr || index > ptr + _remain_data_size) {
throw std::out_of_range("上层分包逻辑异常");
}
//_content_len == 0这是请求头
const char *header_ptr = ptr;
ssize_t header_size = index - ptr;