-
Notifications
You must be signed in to change notification settings - Fork 186
Fix: in the WebSocket Client add-on, fix the base64 encoding #396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -512,6 +512,9 @@ NX_PACKET *packet_ptr; | |
| client_ptr -> nx_websocket_client_guid[i] = (UCHAR)(NX_RAND()); | ||
| } | ||
|
|
||
| /* Set the last extra byte of the buffer to be zero, since the function _nx_utility_base64_encode will use this extra-byte for calculation */ | ||
| client_ptr -> nx_websocket_client_guid[NX_WEBSOCKET_CLIENT_GUID_SIZE] = 0; | ||
|
|
||
| /* Encode the GUID as key. */ | ||
| _nx_utility_base64_encode(client_ptr -> nx_websocket_client_guid, NX_WEBSOCKET_CLIENT_GUID_SIZE, | ||
| client_ptr -> nx_websocket_client_key, NX_WEBSOCKET_CLIENT_KEY_SIZE, | ||
|
|
@@ -963,7 +966,7 @@ UCHAR *field_name; | |
| UINT field_name_length; | ||
| UCHAR *field_value; | ||
| UINT field_value_length; | ||
| UCHAR digest[NX_WEBSOCKET_ACCEPT_DIGEST_SIZE]; | ||
| UCHAR digest[NX_WEBSOCKET_ACCEPT_DIGEST_SIZE + 1]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| UCHAR key[NX_WEBSOCKET_ACCEPT_KEY_SIZE + 1]; | ||
| UINT key_size = 0; | ||
| UCHAR upgrade_flag = NX_FALSE; | ||
|
|
@@ -1104,6 +1107,9 @@ UCHAR accept_cnt = 0; | |
| _nx_sha1_update(&(client_ptr -> nx_websocket_client_sha1), (UCHAR*)NX_WEBSOCKET_ACCEPT_PREDEFINED_GUID, NX_WEBSOCKET_ACCEPT_PREDEFINED_GUID_SIZE); | ||
| _nx_sha1_digest_calculate(&(client_ptr -> nx_websocket_client_sha1), digest); | ||
|
|
||
| /* Set the last extra byte of the digest to be zero, since the function _nx_utility_base64_encode will use this byte for calculation */ | ||
| digest[NX_WEBSOCKET_ACCEPT_DIGEST_SIZE] = 0; | ||
|
|
||
|
Comment on lines
+1110
to
+1112
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| /* Encode the hash and compare it with the field value from the server. */ | ||
| _nx_utility_base64_encode(digest, NX_WEBSOCKET_ACCEPT_DIGEST_SIZE, key, (NX_WEBSOCKET_ACCEPT_KEY_SIZE + 1), &key_size); | ||
| if ((field_value_length != NX_WEBSOCKET_ACCEPT_KEY_SIZE) || (memcmp((void *)field_value, (void *)key, NX_WEBSOCKET_ACCEPT_KEY_SIZE))) /* Use case of memcpy is verified. */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -173,7 +173,7 @@ typedef struct NX_WEBSOCKET_CLIENT_STRUCT | |
| NX_PACKET *nx_websocket_client_processing_packet; | ||
|
|
||
| /* Globally Unique Identifier. */ | ||
| UCHAR nx_websocket_client_guid[NX_WEBSOCKET_CLIENT_GUID_SIZE]; | ||
| UCHAR nx_websocket_client_guid[NX_WEBSOCKET_CLIENT_GUID_SIZE + 1]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| /* Protocol Name and length */ | ||
| UCHAR *nx_websocket_client_subprotocol; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.