diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-09-23 12:05:36 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-09-23 12:05:36 +0100 |
commit | e4fcd0fcda0d192b068dc28eb317e09dc0eb3a12 (patch) | |
tree | 2c8db056f1cb0abd24299a1fb900527727e4a4fa /contrib | |
parent | 9029b54e9f2a3173391e630c8cff5758f2d56321 (diff) | |
download | rspamd-e4fcd0fcda0d192b068dc28eb317e09dc0eb3a12.tar.gz rspamd-e4fcd0fcda0d192b068dc28eb317e09dc0eb3a12.zip |
[Minor] Allow to skip IDN checks in rdns
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/librdns/dns_private.h | 1 | ||||
-rw-r--r-- | contrib/librdns/packet.c | 18 | ||||
-rw-r--r-- | contrib/librdns/rdns.h | 7 | ||||
-rw-r--r-- | contrib/librdns/resolver.c | 15 |
4 files changed, 26 insertions, 15 deletions
diff --git a/contrib/librdns/dns_private.h b/contrib/librdns/dns_private.h index 3f0bee437..76bfba8fe 100644 --- a/contrib/librdns/dns_private.h +++ b/contrib/librdns/dns_private.h @@ -151,6 +151,7 @@ struct rdns_resolver { bool async_binded; bool initialized; bool enable_dnssec; + int flags; ref_entry_t ref; }; diff --git a/contrib/librdns/packet.c b/contrib/librdns/packet.c index 35f4a9601..cdb524705 100644 --- a/contrib/librdns/packet.c +++ b/contrib/librdns/packet.c @@ -105,21 +105,25 @@ rdns_format_dns_name (struct rdns_resolver *resolver, const char *in, } /* Check for non-ascii characters */ - while (p != end) { - if (*p >= 0x80) { - need_encode = true; - } - else if (*p == '.') { - labels ++; + if (!(resolver->flags & RDNS_RESOLVER_NOIDN)) { + while (p != end) { + if (*p >= 0x80) { + need_encode = true; + } + else if (*p == '.') { + labels++; + } + p++; } - p ++; } if (!need_encode) { *out = malloc (inlen + 1); + if (*out == NULL) { return false; } + o = *out; memcpy (o, in, inlen); o[inlen] = '\0'; diff --git a/contrib/librdns/rdns.h b/contrib/librdns/rdns.h index 5ea8f5952..4df1991fd 100644 --- a/contrib/librdns/rdns.h +++ b/contrib/librdns/rdns.h @@ -233,10 +233,15 @@ struct rdns_request_name { * RDNS API */ +enum rdns_resolver_flags { + RDNS_RESOLVER_DEFAULT, + RDNS_RESOLVER_NOIDN = (1u << 0u), +}; + /** * Create DNS resolver structure */ -struct rdns_resolver *rdns_resolver_new (void); +struct rdns_resolver *rdns_resolver_new (int flags); /** * Bind resolver to specified async context diff --git a/contrib/librdns/resolver.c b/contrib/librdns/resolver.c index 98807f38e..3dd44012e 100644 --- a/contrib/librdns/resolver.c +++ b/contrib/librdns/resolver.c @@ -1049,18 +1049,19 @@ rdns_resolver_free (struct rdns_resolver *resolver) struct rdns_resolver * -rdns_resolver_new (void) +rdns_resolver_new (int flags) { - struct rdns_resolver *new; + struct rdns_resolver *new_resolver; - new = calloc (1, sizeof (struct rdns_resolver)); + new_resolver = calloc (1, sizeof (struct rdns_resolver)); - REF_INIT_RETAIN (new, rdns_resolver_free); + REF_INIT_RETAIN (new_resolver, rdns_resolver_free); - new->logger = rdns_logger_internal; - new->log_data = new; + new_resolver->logger = rdns_logger_internal; + new_resolver->log_data = new_resolver; + new_resolver->flags = flags; - return new; + return new_resolver; } void |