Ping and Pong messages cannot be fragmented (autobahn test: 5.1 and 5.2 Fragmentation)
This commit is contained in:
parent
2887370666
commit
61eb662e5f
@ -1,6 +1,10 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [5.1.2] - 2019-09-02
|
||||
|
||||
Ping and Pong messages cannot be fragmented (autobahn test: 5.1 and 5.2 Fragmentation)
|
||||
|
||||
## [5.1.1] - 2019-09-01
|
||||
|
||||
Close connections when reserved bits are used (autobahn test: 3 Reserved Bits)
|
||||
|
@ -21,4 +21,6 @@ namespace ix
|
||||
const std::string WebSocketCloseConstants::kProtocolErrorMessage("Protocol error");
|
||||
const std::string WebSocketCloseConstants::kNoStatusCodeErrorMessage("No status code");
|
||||
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");
|
||||
}
|
||||
|
@ -26,5 +26,7 @@ namespace ix
|
||||
static const std::string kProtocolErrorMessage;
|
||||
static const std::string kNoStatusCodeErrorMessage;
|
||||
static const std::string kProtocolErrorReservedBitUsed;
|
||||
static const std::string kProtocolErrorPingPayloadOversized;
|
||||
static const std::string kProtocolErrorCodeControlMessageFragmented;
|
||||
};
|
||||
} // namespace ix
|
||||
|
@ -546,6 +546,17 @@ namespace ix
|
||||
return; /* Need: ws.header_size+ws.N - _rxbuf.size() */
|
||||
}
|
||||
|
||||
if (!ws.fin && (
|
||||
ws.opcode == wsheader_type::PING
|
||||
|| ws.opcode == wsheader_type::PONG
|
||||
|| ws.opcode == wsheader_type::CLOSE
|
||||
)){
|
||||
// Cntrol messages should not be fragmented
|
||||
close(WebSocketCloseConstants::kProtocolErrorCode,
|
||||
WebSocketCloseConstants::kProtocolErrorCodeControlMessageFragmented);
|
||||
return;
|
||||
}
|
||||
|
||||
// We got a whole message, now do something with it:
|
||||
if (
|
||||
ws.opcode == wsheader_type::TEXT_FRAME
|
||||
@ -603,11 +614,9 @@ namespace ix
|
||||
// too large
|
||||
if (pingData.size() > 125)
|
||||
{
|
||||
std::string reason("reason control frame with payload length > 125 octets");
|
||||
// Unexpected frame type
|
||||
close(1002,
|
||||
reason,
|
||||
reason.size());
|
||||
close(WebSocketCloseConstants::kProtocolErrorCode,
|
||||
WebSocketCloseConstants::kProtocolErrorPingPayloadOversized);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1070,6 +1079,11 @@ namespace ix
|
||||
|
||||
if (_readyState == ReadyState::CLOSING || _readyState == ReadyState::CLOSED) return;
|
||||
|
||||
if (closeWireSize == 0)
|
||||
{
|
||||
closeWireSize = reason.size();
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_closeDataMutex);
|
||||
_closeCode = code;
|
||||
|
@ -6,4 +6,4 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define IX_WEBSOCKET_VERSION "5.1.1"
|
||||
#define IX_WEBSOCKET_VERSION "5.1.2"
|
||||
|
Loading…
Reference in New Issue
Block a user