]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_dns.cpp
Merge branch 'master+dns'
[user/henk/code/inspircd.git] / src / coremods / core_dns.cpp
index d4214b9a5ec313be8b354063cd5072e8a7d33d56..829351f04dceec1cc07ee37786ced76aaf1b9a85 100644 (file)
@@ -33,6 +33,11 @@ using namespace DNS;
  */
 class Packet : public Query
 {
+       static bool IsValidName(const std::string& name)
+       {
+               return (name.find_first_not_of("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-") == std::string::npos);
+       }
+
        void PackName(unsigned char* output, unsigned short output_size, unsigned short& pos, const std::string& name)
        {
                if (pos + name.length() + 2 > output_size)
@@ -183,6 +188,9 @@ class Packet : public Query
                        case QUERY_PTR:
                        {
                                record.rdata = this->UnpackName(input, input_size, pos);
+                               if (!IsValidName(record.rdata))
+                                       throw Exception("Invalid name"); // XXX: Causes the request to time out
+
                                break;
                        }
                        default: