Skip to content

Commit b6015b9

Browse files
committed
Fix message size not accounting for negative numbers
1 parent 1c7566c commit b6015b9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/bridge/BridgeTransport.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ 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>(len_buf[0]) << 0;
85-
size |= static_cast<uint32_t>(len_buf[1]) << 8;
86-
size |= static_cast<uint32_t>(len_buf[2]) << 16;
87-
size |= static_cast<uint32_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("message size overflow");
91+
logger_->Log(std::to_string(size).c_str());
9192
ResetConnection();
9293
return;
9394
}

0 commit comments

Comments
 (0)