Skip to content

Commit a183b42

Browse files
committed
Fix message size not accounting for negative numbers
1 parent b8dfa60 commit a183b42

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/bridge/BridgeTransport.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ void BridgeTransport::OnRecv(const uvw::data_event& event) {
8181
char len_buf[4];
8282
recv_buf_.Peek(len_buf, 4);
8383
uint32_t size = 0;
84-
size |= static_cast<uint32_t>(static_cast<uint8_t>(len_buf[0])) << 0;
85-
size |= static_cast<uint32_t>(static_cast<uint8_t>(len_buf[1])) << 8;
86-
size |= static_cast<uint32_t>(static_cast<uint8_t>(len_buf[2])) << 16;
87-
size |= static_cast<uint32_t>(static_cast<uint8_t>(len_buf[3])) << 24;
84+
size = static_cast<uint32_t>(static_cast<uint8_t>(len_buf[0])) |
85+
(static_cast<uint32_t>(static_cast<uint8_t>(len_buf[1])) << 8) |
86+
(static_cast<uint32_t>(static_cast<uint8_t>(len_buf[2])) << 16) |
87+
(static_cast<uint32_t>(static_cast<uint8_t>(len_buf[3])) << 24);
8888

8989
if (size > VRBRIDGE_MAX_MESSAGE_SIZE) {
9090
logger_->Log(

0 commit comments

Comments
 (0)