diff --git a/src/anbox/rpc/channel.cpp b/src/anbox/rpc/channel.cpp index 71ffa80..b0c2ead 100644 --- a/src/anbox/rpc/channel.cpp +++ b/src/anbox/rpc/channel.cpp @@ -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((size >>16) & 0xff), static_cast((size >> 8) & 0xff), static_cast((size >> 0) & 0xff), type, }; diff --git a/src/anbox/rpc/constants.h b/src/anbox/rpc/constants.h index 1d4265a..4f5d04a 100644 --- a/src/anbox/rpc/constants.h +++ b/src/anbox/rpc/constants.h @@ -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 { diff --git a/src/anbox/rpc/message_processor.cpp b/src/anbox/rpc/message_processor.cpp index 90e70ef..ba25a5a 100644 --- a/src/anbox/rpc/message_processor.cpp +++ b/src/anbox/rpc/message_processor.cpp @@ -47,9 +47,10 @@ bool MessageProcessor::process_data(const std::vector &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((size >> 16) & 0xff), static_cast((size >> 8) & 0xff), static_cast((size >> 0) & 0xff), MessageType::response, };