fix: cast len to 64 bits before right shift in ws (#2426)

Fixes WebSocketIntegrationTest.LargeMessage and
WebSocketIntegrationTest.MaxPayloadAtLimit on i386
This commit is contained in:
Andrea Pappacoda authored and GitHub committed 2026-04-12 17:27:16 -04:00
1 parent 7e2a173072
commit cb3fce964d
1 file changed
+2 -1
+2 -1
View File
@@ -4727,7 +4727,8 @@ inline bool write_websocket_frame(Stream &strm, ws::Opcode opcode,
if (strm.write(reinterpret_cast<char *>(header), 2) < 0) { return false; } if (strm.write(reinterpret_cast<char *>(header), 2) < 0) { return false; }
uint8_t ext[8]; uint8_t ext[8];
for (int i = 7; i >= 0; i--) { for (int i = 7; i >= 0; i--) {
ext[7 - i] = static_cast<uint8_t>((len >> (i * 8)) & 0xFF); ext[7 - i] =
static_cast<uint8_t>((static_cast<uint64_t>(len) >> (i * 8)) & 0xFF);
} }
if (strm.write(reinterpret_cast<char *>(ext), 8) < 0) { return false; } if (strm.write(reinterpret_cast<char *>(ext), 8) < 0) { return false; }
} }