mirror of https://github.com/procxx/kepka.git
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) {
|
for (auto i = 0; i != count; ++i) {
|
||||||
qint32 id = 0, flags = 0, port = 0, ipSize = 0;
|
qint32 id = 0, flags = 0, port = 0, ipSize = 0;
|
||||||
stream >> id >> flags >> port >> ipSize;
|
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, ' ');
|
std::string ip(ipSize, ' ');
|
||||||
stream.readRawData(&ip[0], ipSize);
|
stream.readRawData(&ip[0], ipSize);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue