]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Reject replies to DNS PTR requests that contain invalid characters
authorAttila Molnar <attilamolnar@hush.com>
Thu, 16 Apr 2015 16:04:03 +0000 (18:04 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Thu, 16 Apr 2015 16:04:03 +0000 (18:04 +0200)
Fixes issue #1033 reported by @ping86

src/dns.cpp

index 75e5731fe93edac1951162665719424370b9b79f..14305ccab2f49a2a4e94f94ee67dc543c34e92c2 100644 (file)
@@ -700,8 +700,16 @@ DNSResult DNS::GetResult()
                                /* Identical handling to PTR */
 
                        case DNS_QUERY_PTR:
+                       {
                                /* Reverse lookups just come back as char* */
                                resultstr = std::string((const char*)data.first);
+                               if (resultstr.find_first_not_of("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-") != std::string::npos)
+                               {
+                                       std::string ro = req->orig;
+                                       delete req;
+                                       return DNSResult(this_id | ERROR_MASK, "Invalid char(s) in reply", 0, ro);
+                               }
+                       }
                        break;
 
                        default: