Open alanswx opened 5 years ago
I think this old issue can be closed.
The assumption that header[3+X] needs to be changed to header[1+X] is wrong: The size will be stored two bytes after the opcode (reference https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers )
The 64bit width of size_t is still a problem, so for unrealistic big packages the type of len should be changed to ssize_t, too. https://github.com/davidmoreno/onion/blob/2b3b230b79ecae119b7eb847f2f9545a46bef13c/src/onion/websocket.c#L205
in: https://github.com/davidmoreno/onion/blob/master/src/onion/websocket.c#L207
header[3 + 8 - i] = tlen & 0x0FF;
I am pretty sure the 3 should be a 1:
header[1 + 8 - i] = tlen & 0x0FF;
There may also be a 32 vs 64 bit problem on systems where int isn't 64 bits.