diff options
| author | 2024-07-29 15:44:01 +0100 | |
|---|---|---|
| committer | 2024-07-29 15:44:01 +0100 | |
| commit | a5503a9f5ee1c75774236834c9c0ca34f75949c4 (patch) | |
| tree | 76908c314d3fb50d863f33c6631d8875fe0cc352 /src/socket.cpp | |
| parent | Log when a user has an unknown socket type in User::GetCIDRMask. (diff) | |
Avoid passing malformed socket addresses to sa2cidr.
Diffstat (limited to 'src/socket.cpp')
| -rw-r--r-- | src/socket.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/socket.cpp b/src/socket.cpp index de96c0a57..1d77faf4e 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -484,13 +484,21 @@ irc::sockets::cidr_mask::cidr_mask(const std::string& mask) if (bits_chars == std::string::npos) { - sa.from_ip(mask); + if (!sa.from_ip(mask)) + { + memset(this, 0, sizeof(*this)); + return; + } sa2cidr(*this, sa, 128); } else { unsigned char range = ConvToNum<unsigned char>(mask.substr(bits_chars + 1)); - sa.from_ip(mask.substr(0, bits_chars)); + if (!sa.from_ip(mask.substr(0, bits_chars))) + { + memset(this, 0, sizeof(*this)); + return; + } sa2cidr(*this, sa, range); } } |
