Framentation: data and continuation blocks received out of order (fix autobahn test: 5.9 through 5.20 Fragmentation)
This commit is contained in:
		| @@ -1 +1 @@ | ||||
| 5.1.4 | ||||
| 5.1.5 | ||||
|   | ||||
| @@ -1,6 +1,10 @@ | ||||
| # Changelog | ||||
| All notable changes to this project will be documented in this file. | ||||
|  | ||||
| ## [5.1.5] - 2019-09-03 | ||||
|  | ||||
| Framentation: data and continuation blocks received out of order (fix autobahn test: 5.9 through 5.20 Fragmentation) | ||||
|  | ||||
| ## [5.1.4] - 2019-09-03 | ||||
|  | ||||
| Sending invalid UTF-8 TEXT message should fail and close the connection (fix **tons** of autobahn test: 6.X UTF-8 Handling) | ||||
| @@ -19,17 +23,17 @@ Close connections when reserved bits are used (fix autobahn test: 3.X Reserved B | ||||
|  | ||||
| ## [5.1.0] - 2019-08-31 | ||||
|  | ||||
| ws autobahn / Add code to test websocket client compliance with the autobahn test-suite | ||||
| add utf-8 validation code, not hooked up properly yet | ||||
| Ping received with a payload too large (> 125 bytes) trigger a connection closure | ||||
| cobra / add tracking about published messages | ||||
| cobra / publish returns a message id, that can be used when  | ||||
| cobra / new message type in the message received handler when publish/ok is received (can be used to implement an ack system). | ||||
| - ws autobahn / Add code to test websocket client compliance with the autobahn test-suite | ||||
| - add utf-8 validation code, not hooked up properly yet | ||||
| - Ping received with a payload too large (> 125 bytes) trigger a connection closure | ||||
| - cobra / add tracking about published messages | ||||
| - cobra / publish returns a message id, that can be used when  | ||||
| - cobra / new message type in the message received handler when publish/ok is received (can be used to implement an ack system). | ||||
|  | ||||
| ## [5.0.9] - 2019-08-30 | ||||
|  | ||||
| User-Agent header is set when not specified. | ||||
| New option to cap the max wait between reconnection attempts. Still default to 10s. (setMaxWaitBetweenReconnectionRetries). | ||||
| - User-Agent header is set when not specified. | ||||
| - New option to cap the max wait between reconnection attempts. Still default to 10s. (setMaxWaitBetweenReconnectionRetries). | ||||
|  | ||||
| ``` | ||||
| ws connect --max_wait 5000 ws://example.com # will only wait 5 seconds max between reconnection attempts | ||||
|   | ||||
| @@ -461,8 +461,8 @@ namespace ix | ||||
|     { | ||||
|         if (!isValidUtf8(text)) | ||||
|         { | ||||
|             close(WebSocketCloseConstants::kNormalClosureCode, | ||||
|                   WebSocketCloseConstants::kInvalidUtf8); | ||||
|             close(WebSocketCloseConstants::kInvalidFramePayloadData, | ||||
|                   WebSocketCloseConstants::kInvalidFramePayloadDataMessage); | ||||
|             return false; | ||||
|         } | ||||
|         return sendMessage(text, SendMessageKind::Text, onProgressCallback); | ||||
|   | ||||
| @@ -11,6 +11,7 @@ namespace ix | ||||
|     const uint16_t WebSocketCloseConstants::kNormalClosureCode(1000); | ||||
|     const uint16_t WebSocketCloseConstants::kInternalErrorCode(1011); | ||||
|     const uint16_t WebSocketCloseConstants::kAbnormalCloseCode(1006); | ||||
|     const uint16_t WebSocketCloseConstants::kInvalidFramePayloadData(1007); | ||||
|     const uint16_t WebSocketCloseConstants::kProtocolErrorCode(1002); | ||||
|     const uint16_t WebSocketCloseConstants::kNoStatusCodeErrorCode(1005); | ||||
|  | ||||
| @@ -23,5 +24,7 @@ namespace ix | ||||
|     const std::string WebSocketCloseConstants::kProtocolErrorReservedBitUsed("Reserved bit used"); | ||||
|     const std::string WebSocketCloseConstants::kProtocolErrorPingPayloadOversized("Ping reason control frame with payload length > 125 octets"); | ||||
|     const std::string WebSocketCloseConstants::kProtocolErrorCodeControlMessageFragmented("Control message fragmented"); | ||||
|     const std::string WebSocketCloseConstants::kInvalidUtf8("Invalid UTF-8"); | ||||
|     const std::string WebSocketCloseConstants::kProtocolErrorCodeDataOpcodeOutOfSequence("Fragmentation: data message out of sequence"); | ||||
|     const std::string WebSocketCloseConstants::kProtocolErrorCodeContinuationOpCodeOutOfSequence("Fragmentation: continuation opcode out of sequence"); | ||||
|     const std::string WebSocketCloseConstants::kInvalidFramePayloadDataMessage("Invalid frame payload data"); | ||||
| } | ||||
|   | ||||
| @@ -18,6 +18,7 @@ namespace ix | ||||
|         static const uint16_t kAbnormalCloseCode; | ||||
|         static const uint16_t kProtocolErrorCode; | ||||
|         static const uint16_t kNoStatusCodeErrorCode; | ||||
|         static const uint16_t kInvalidFramePayloadData; | ||||
|  | ||||
|         static const std::string kNormalClosureMessage; | ||||
|         static const std::string kInternalErrorMessage; | ||||
| @@ -28,6 +29,8 @@ namespace ix | ||||
|         static const std::string kProtocolErrorReservedBitUsed; | ||||
|         static const std::string kProtocolErrorPingPayloadOversized; | ||||
|         static const std::string kProtocolErrorCodeControlMessageFragmented; | ||||
|         static const std::string kInvalidUtf8; | ||||
|         static const std::string kProtocolErrorCodeDataOpcodeOutOfSequence; | ||||
|         static const std::string kProtocolErrorCodeContinuationOpCodeOutOfSequence; | ||||
|         static const std::string kInvalidFramePayloadDataMessage; | ||||
|     }; | ||||
| } // namespace ix | ||||
|   | ||||
| @@ -551,7 +551,7 @@ namespace ix | ||||
|                 || ws.opcode == wsheader_type::PONG | ||||
|                 || ws.opcode == wsheader_type::CLOSE | ||||
|             )){ | ||||
|                 // Cntrol messages should not be fragmented | ||||
|                 // Control messages should not be fragmented | ||||
|                 close(WebSocketCloseConstants::kProtocolErrorCode, | ||||
|                       WebSocketCloseConstants::kProtocolErrorCodeControlMessageFragmented); | ||||
|                 return; | ||||
| @@ -571,6 +571,19 @@ namespace ix | ||||
|                         (ws.opcode == wsheader_type::TEXT_FRAME) | ||||
|                         ? MessageKind::MSG_TEXT | ||||
|                         : MessageKind::MSG_BINARY; | ||||
|  | ||||
|                     // Continuation message needs to follow a non-fin TEXT or BINARY message | ||||
|                     if (!_chunks.empty()) | ||||
|                     { | ||||
|                         close(WebSocketCloseConstants::kProtocolErrorCode, | ||||
|                               WebSocketCloseConstants::kProtocolErrorCodeDataOpcodeOutOfSequence); | ||||
|                     } | ||||
|                 } | ||||
|                 else if (_chunks.empty()) | ||||
|                 { | ||||
|                     // Continuation message need to follow a non-fin TEXT or BINARY message | ||||
|                     close(WebSocketCloseConstants::kProtocolErrorCode, | ||||
|                           WebSocketCloseConstants::kProtocolErrorCodeContinuationOpCodeOutOfSequence); | ||||
|                 } | ||||
|  | ||||
|                 // | ||||
|   | ||||
| @@ -6,4 +6,4 @@ | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #define IX_WEBSOCKET_VERSION "5.1.4" | ||||
| #define IX_WEBSOCKET_VERSION "5.1.5" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user