aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/librdns
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-01-22 16:54:34 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-01-22 16:54:34 +0000
commita0b6284734f906f188c05c925b9e2077172f337e (patch)
treeb6ba17835a3891cb667346c5a8195904d9254088 /contrib/librdns
parentbbbfedc8a55a7a4965bc5d5e1d1d5fbaff00294a (diff)
downloadrspamd-a0b6284734f906f188c05c925b9e2077172f337e.tar.gz
rspamd-a0b6284734f906f188c05c925b9e2077172f337e.zip
[Minor] RDNS: Filter starting and trailing dots in DNS names
Diffstat (limited to 'contrib/librdns')
-rw-r--r--contrib/librdns/resolver.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/contrib/librdns/resolver.c b/contrib/librdns/resolver.c
index b38e90514..522ec0d9c 100644
--- a/contrib/librdns/resolver.c
+++ b/contrib/librdns/resolver.c
@@ -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);