mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-19 11:19:36 +00:00
Treat a zero WebSocket payload limit as none
CPPHTTPLIB_WEBSOCKET_MAX_PAYLOAD_LENGTH = 0 rejected every frame with a payload, while 0 means no limit for payload_max_length. Make it mean the same here, and refuse a length that size_t cannot hold.
This commit is contained in:
1 parent
194f392417
commit
0116be0a2b
3 files changed
+28
-3
No files matched your search
@@ -5758,7 +5758,11 @@ inline FrameRead read_websocket_frame(Stream &strm, Opcode &opcode,
|
||||
}
|
||||
}
|
||||
|
||||
if (payload_len > max_len) { return FrameRead::Fail; }
|
||||
// A max_len of 0 means no limit, as payload_max_length does.
|
||||
if ((max_len > 0 && payload_len > max_len) ||
|
||||
payload_len > (std::numeric_limits<size_t>::max)()) {
|
||||
return FrameRead::Fail;
|
||||
}
|
||||
|
||||
// Read mask key if present
|
||||
uint8_t mask_key[4] = {0};
|
||||
@@ -22887,7 +22891,8 @@ inline ReadResult WebSocket::read(std::string &msg) {
|
||||
return Fail;
|
||||
}
|
||||
msg += cont_payload;
|
||||
if (msg.size() > CPPHTTPLIB_WEBSOCKET_MAX_PAYLOAD_LENGTH) {
|
||||
if (CPPHTTPLIB_WEBSOCKET_MAX_PAYLOAD_LENGTH > 0 &&
|
||||
msg.size() > CPPHTTPLIB_WEBSOCKET_MAX_PAYLOAD_LENGTH) {
|
||||
closed_ = true;
|
||||
return Fail;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user