]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] RDNS: Filter starting and trailing dots in DNS names
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Jan 2019 16:54:34 +0000 (16:54 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Jan 2019 16:54:34 +0000 (16:54 +0000)
contrib/librdns/resolver.c

index b38e90514e54af8edce6d2013a53545baa1d54a1..522ec0d9cba0f2b81c20af709291f96e77fc0a6c 100644 (file)
@@ -605,6 +605,33 @@ rdns_make_request_full (
                                return NULL;
                        }
 
+                       if (cur_name[0] == '.') {
+                               /* Skip dots at the begin */
+                               unsigned int ndots = strspn (cur_name, ".");
+
+                               cur_name += ndots;
+                               clen -= ndots;
+
+                               if (clen == 0) {
+                                       rdns_warn ("got empty name to resolve");
+                                       rdns_request_free (req);
+                                       return NULL;
+                               }
+                       }
+
+                       if (cur_name[clen - 1] == '.') {
+                               /* Skip trailing dots */
+                               while (clen >= 1 && cur_name[clen - 1] == '.') {
+                                       clen --;
+                               }
+
+                               if (clen == 0) {
+                                       rdns_warn ("got empty name to resolve");
+                                       rdns_request_free (req);
+                                       return NULL;
+                               }
+                       }
+
                        if (last_name == NULL && queries == 1 && clen < MAX_FAKE_NAME) {
                                /* We allocate structure in the static space */
                                idx = (struct rdns_fake_reply_idx *)align_ptr (fake_buf, 16);