Merge pull request #712 from Jiancong/master
Fix session-manager corrupted caused by memory overflow.
This commit is contained in:
commit
807005b2fa
3 changed files with 7 additions and 4 deletions
|
|
@ -74,6 +74,7 @@ void Channel::send_message(const std::uint8_t &type,
|
|||
google::protobuf::MessageLite const &message) {
|
||||
const size_t size = message.ByteSize();
|
||||
const unsigned char header_bytes[header_size] = {
|
||||
static_cast<unsigned char>((size >>16) & 0xff),
|
||||
static_cast<unsigned char>((size >> 8) & 0xff),
|
||||
static_cast<unsigned char>((size >> 0) & 0xff), type,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
namespace anbox {
|
||||
namespace rpc {
|
||||
static constexpr const long header_size{3};
|
||||
static constexpr const long header_size{4};
|
||||
static constexpr unsigned int const serialization_buffer_size{2048};
|
||||
|
||||
enum MessageType {
|
||||
|
|
|
|||
|
|
@ -47,9 +47,10 @@ bool MessageProcessor::process_data(const std::vector<std::uint8_t> &data) {
|
|||
|
||||
while (buffer_.size() > 0) {
|
||||
const auto high = buffer_[0];
|
||||
const auto low = buffer_[1];
|
||||
size_t const message_size = (high << 8) + low;
|
||||
const auto message_type = buffer_[2];
|
||||
const auto medium = buffer_[1];
|
||||
const auto low = buffer_[2];
|
||||
size_t const message_size = (high << 16) + (medium << 8) + low;
|
||||
const auto message_type = buffer_[3];
|
||||
|
||||
// If we don't have yet all bytes for a new message return and wait
|
||||
// until we have all.
|
||||
|
|
@ -101,6 +102,7 @@ void MessageProcessor::send_response(::google::protobuf::uint32 id,
|
|||
|
||||
const size_t size = send_response_buffer.size();
|
||||
const unsigned char header_bytes[header_size] = {
|
||||
static_cast<unsigned char>((size >> 16) & 0xff),
|
||||
static_cast<unsigned char>((size >> 8) & 0xff),
|
||||
static_cast<unsigned char>((size >> 0) & 0xff), MessageType::response,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue