From 2efa10440079ad872c166b371fc18976308454bf Mon Sep 17 00:00:00 2001 From: cyshi Date: Fri, 30 Dec 2016 12:52:26 +0800 Subject: [PATCH] add judgement condition for bytes_remain --- src/sofa/pbrpc/binary_rpc_request_parser.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sofa/pbrpc/binary_rpc_request_parser.cc b/src/sofa/pbrpc/binary_rpc_request_parser.cc index 9d892be..879826c 100644 --- a/src/sofa/pbrpc/binary_rpc_request_parser.cc +++ b/src/sofa/pbrpc/binary_rpc_request_parser.cc @@ -86,15 +86,15 @@ int BinaryRpcRequestParser::Parse(const char* buf, } case PS_MSG_BODY: bytes_remain = _req->_req_header.message_size - _bytes_recved; - if (bytes_remain > MAX_MESSAGE_SIZE) + if (bytes_remain > MAX_MESSAGE_SIZE || bytes_remain <= 0) { - // rpc message size is too large + // compute bytes_remain error #if defined( LOG ) LOG(ERROR) << "Parse(): " << RpcEndpointToString(_req->_remote_endpoint) - << ": message size[" << bytes_remain - << "] exceed the limit[" << MAX_MESSAGE_SIZE << "]"; + << ": compute bytes_remain[" << bytes_remain + << "] error, message size limit[" << MAX_MESSAGE_SIZE << "]"; #else - SLOG(ERROR, "Parse(): %s: message size[%lld] exceed the limit[%lld]", + SLOG(ERROR, "Parse(): %s: compute bytes_remain[%lld] error, message size limit[%lld]", RpcEndpointToString(_req->_remote_endpoint).c_str(), bytes_remain, MAX_MESSAGE_SIZE); #endif