summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2017-07-09 21:46:20 +0200
committerGitHub <noreply@github.com>2017-07-09 21:46:20 +0200
commite97ee390cf1a3f5e897aed85d62e29a34c4632f9 (patch)
tree54d49ec9b8b1654923243c5b15e7e01f4eca3078
parente9d645cd301c1a994e482d43980589969cbf52f1 (diff)
parentf2e3762ff4a2b3690ed70eba5cc0dde9ae045a90 (diff)
Merge pull request #1302 from Adam-/master+txt
core_dns: add support for txt records
-rw-r--r--include/modules/dns.h2
-rw-r--r--src/coremods/core_dns.cpp15
2 files changed, 16 insertions, 1 deletions
diff --git a/include/modules/dns.h b/include/modules/dns.h
index 5f2836761..61abd7144 100644
--- a/include/modules/dns.h
+++ b/include/modules/dns.h
@@ -33,6 +33,8 @@ namespace DNS
QUERY_CNAME = 5,
/* Reverse DNS lookup */
QUERY_PTR = 12,
+ /* TXT */
+ QUERY_TXT = 16,
/* IPv6 AAAA lookup */
QUERY_AAAA = 28
};
diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp
index 753b41f43..7ee406a24 100644
--- a/src/coremods/core_dns.cpp
+++ b/src/coremods/core_dns.cpp
@@ -154,7 +154,7 @@ class Packet : public Query
record.ttl = (input[pos] << 24) | (input[pos + 1] << 16) | (input[pos + 2] << 8) | input[pos + 3];
pos += 4;
- //record.rdlength = input[pos] << 8 | input[pos + 1];
+ uint16_t rdlength = input[pos] << 8 | input[pos + 1];
pos += 2;
switch (record.type)
@@ -200,6 +200,19 @@ class Packet : public Query
break;
}
+ case QUERY_TXT:
+ {
+ if (pos + rdlength > input_size)
+ throw Exception("Unable to unpack txt resource record");
+
+ record.rdata = std::string(reinterpret_cast<const char *>(input + pos), rdlength);
+ pos += rdlength;
+
+ if (record.rdata.find_first_of("\r\n\0", 0, 3) != std::string::npos)
+ throw Exception("Invalid character in txt record");
+
+ break;
+ }
default:
break;
}