mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-16 20:22:03 +00:00
Limit maximum IP length in case of corrupted data.
This commit is contained in:
parent
fbf8cd04b5
commit
5b77bd5aa0
@ -281,6 +281,14 @@ void DcOptions::constructFromSerialized(const QByteArray &serialized) {
|
||||
for (auto i = 0; i != count; ++i) {
|
||||
qint32 id = 0, flags = 0, port = 0, ipSize = 0;
|
||||
stream >> id >> flags >> port >> ipSize;
|
||||
|
||||
// https://stackoverflow.com/questions/1076714/max-length-for-client-ip-address
|
||||
constexpr auto kMaxIpSize = 45;
|
||||
if (ipSize > kMaxIpSize) {
|
||||
LOG(("MTP Error: Bad data inside DcOptions::constructFromSerialized()"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string ip(ipSize, ' ');
|
||||
stream.readRawData(&ip[0], ipSize);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user