Add exception when input SSL buffer is overflown. #6

This commit is contained in:
Michał Słomkowski 2015-12-14 01:44:02 +01:00
parent 7e37c6eb7e
commit 4b8fad8263

View File

@ -292,9 +292,16 @@ void mumlib::Transport::doReceiveSsl() {
} }
const int payloadSize = ntohl(*reinterpret_cast<uint32_t *>(sslIncomingBuffer + 2)); const int payloadSize = ntohl(*reinterpret_cast<uint32_t *>(sslIncomingBuffer + 2));
size_t remaining = payloadSize + 6 - bytesTransferred; const int wholeMessageLength = payloadSize + 6;
size_t remaining = wholeMessageLength - bytesTransferred;
remaining = max(remaining, (size_t) 0); remaining = max(remaining, (size_t) 0);
if (wholeMessageLength > MAX_TCP_LENGTH) {
throwTransportException(
(boost::format("message bigger (%d B) than max allowed size (%d B)")
% wholeMessageLength % MAX_TCP_LENGTH).str());
}
return remaining; return remaining;
}, },
[this](const boost::system::error_code &ec, size_t bytesTransferred) { [this](const boost::system::error_code &ec, size_t bytesTransferred) {