aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Sadie Powell2021-12-25 10:58:49 +0000
committerGravatar Sadie Powell2021-12-25 11:25:18 +0000
commit71c62ea7cb95ce987a7bca41181bf963ecf12d39 (patch)
treea154295b3b9ca0167207a139c3f8e5a014e8406f /src
parentFix not looking up IPv4 addresses when a server has an IPv6 address. (diff)
Make packing PTR queries a bit more robust.
There is no first party modules which could be compromised before this check was added but its better to be safe wherever possible.
Diffstat (limited to 'src')
-rw-r--r--src/coremods/core_dns.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp
index 8ebc1b57d..f3febc36b 100644
--- a/src/coremods/core_dns.cpp
+++ b/src/coremods/core_dns.cpp
@@ -279,7 +279,7 @@ class Packet : public Query
unsigned short Pack(unsigned char* output, unsigned short output_size)
{
if (output_size < HEADER_LENGTH)
- throw Exception("Unable to pack packet");
+ throw Exception("Unable to pack oversized packet header");
unsigned short pos = 0;
@@ -302,7 +302,8 @@ class Packet : public Query
if (q.type == QUERY_PTR)
{
irc::sockets::sockaddrs ip;
- irc::sockets::aptosa(q.name, 0, ip);
+ if (!irc::sockets::aptosa(q.name, 0, ip))
+ throw Exception("Unable to pack packet with malformed IP for PTR lookup");
if (q.name.find(':') != std::string::npos)
{
@@ -333,7 +334,7 @@ class Packet : public Query
this->PackName(output, output_size, pos, q.name);
if (pos + 4 >= output_size)
- throw Exception("Unable to pack packet");
+ throw Exception("Unable to pack oversized packet body");
short s = htons(q.type);
memcpy(&output[pos], &s, 2);