Skip to content

Commit c848fba

Browse files
committed
fix: payload parsing for 64 byte payloads (#32)
PR by [baris-btcturk](chronoxor/NetCoreServer#329)
1 parent 219f2cf commit c848fba

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

release.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ Notes :
2121
## v13.1.0 / _(2025-04-??)_
2222
Maintenance
2323

24+
### fix
25+
26+
- fix payload parsing for 64 byte payloads (#32), PR by [baris-btcturk](https://github.com/chronoxor/NetCoreServer/pull/329)
27+
2428
### feature
2529

2630
- made possible to append extra response http headers in PerformServerUpgrade stage (#31), PR by [lifeengines](https://github.com/chronoxor/NetCoreServer/pull/297) to fix [bramley-jetcharge

src/SimpleW/NetCoreServer/WebSocket.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,16 @@ public void PrepareReceiveFrame(byte[] buffer, long offset, long size)
410410
}
411411
}
412412

413-
payload = ((WsReceiveFrameBuffer[2] << 56) | (WsReceiveFrameBuffer[3] << 48) | (WsReceiveFrameBuffer[4] << 40) | (WsReceiveFrameBuffer[5] << 32) | (WsReceiveFrameBuffer[6] << 24) | (WsReceiveFrameBuffer[7] << 16) | (WsReceiveFrameBuffer[8] << 8) | (WsReceiveFrameBuffer[9] << 0));
413+
// payload, force convert to long with 0xFFL
414+
payload = ((WsReceiveFrameBuffer[2] & 0xFFL) << 56) |
415+
((WsReceiveFrameBuffer[3] & 0xFFL) << 48) |
416+
((WsReceiveFrameBuffer[4] & 0xFFL) << 40) |
417+
((WsReceiveFrameBuffer[5] & 0xFFL) << 32) |
418+
((WsReceiveFrameBuffer[6] & 0xFFL) << 24) |
419+
((WsReceiveFrameBuffer[7] & 0xFFL) << 16) |
420+
((WsReceiveFrameBuffer[8] & 0xFFL) << 8) |
421+
((WsReceiveFrameBuffer[9] & 0xFFL));
422+
414423
WsHeaderSize = 10 + (mask ? 4 : 0);
415424
WsPayloadSize = payload;
416425
}

0 commit comments

Comments
 (0)