I had broken this for NT4 compat earlier, i manually reimplemented ntohll inline in the tlen == 127 check
This commit is contained in:
@@ -106,7 +106,7 @@ DWORD WINAPI WSThreadProc(LPVOID ssl) {
|
||||
|
||||
if (length != 0 && result != 0) {
|
||||
WebSocketOnDataArrival(ssl, buffer, length);
|
||||
// printf("%s\n",buffer);
|
||||
printf("%s\n", buffer);
|
||||
// LE IMPORTANT: free the buffer after processing... memleak goez
|
||||
// brr otherewise
|
||||
free(buffer);
|
||||
@@ -118,6 +118,7 @@ DWORD WINAPI WSThreadProc(LPVOID ssl) {
|
||||
};
|
||||
int SendWebSocket(SSL *ssl, const char *data, size_t length,
|
||||
unsigned char flags) {
|
||||
printf("%s\n", data);
|
||||
unsigned char frame[14];
|
||||
size_t frame_size = 0;
|
||||
|
||||
@@ -153,7 +154,8 @@ int SendWebSocket(SSL *ssl, const char *data, size_t length,
|
||||
mask[i] = (unsigned char)(i & 0xFF);
|
||||
}
|
||||
|
||||
RtlCopyMemory(&frame[frame_size], mask, 4); // me when i rtlcopymemory to look cool
|
||||
RtlCopyMemory(&frame[frame_size], mask,
|
||||
4); // me when i rtlcopymemory to look cool
|
||||
frame_size += 4;
|
||||
|
||||
// Send frame header
|
||||
@@ -200,8 +202,15 @@ int ReadWebSocket(SSL *ssl, char **out_buffer, size_t *out_length) {
|
||||
SSL_read(ssl, &plHeaders, 1);
|
||||
unsigned char tlen = (plHeaders << 1) >> 1;
|
||||
if (tlen == 127) {
|
||||
SSL_read(ssl, &curPayloadLen, 8);
|
||||
curPayloadLen = ntohl(curPayloadLen);
|
||||
unsigned char lenbytes[8];
|
||||
SSL_read(ssl, lenbytes,8);
|
||||
curPayloadLen = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
unsigned char temp = lenbytes[i];
|
||||
lenbytes[i]=lenbytes[7-i];
|
||||
lenbytes[7-i]=temp;
|
||||
}
|
||||
curPayloadLen = *(unsigned long long*)lenbytes;
|
||||
payloadLen += curPayloadLen;
|
||||
} else if (tlen == 126) {
|
||||
unsigned short templen;
|
||||
|
||||
Reference in New Issue
Block a user