diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-06-11 15:43:22 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-06-11 15:43:22 +0100 |
commit | f30371e886c11afd75e3f7e7e95bd59ffed72ec9 (patch) | |
tree | 5121652d539534abb39dd51ce7a4933f3d95d941 /contrib/librdns | |
parent | 6b07a361d0f9a97ea2734add840c115e1dd183fd (diff) | |
download | rspamd-f30371e886c11afd75e3f7e7e95bd59ffed72ec9.tar.gz rspamd-f30371e886c11afd75e3f7e7e95bd59ffed72ec9.zip |
[Minor] Fix hash lookup
Diffstat (limited to 'contrib/librdns')
-rw-r--r-- | contrib/librdns/dns_private.h | 3 | ||||
-rw-r--r-- | contrib/librdns/rdns.h | 1 | ||||
-rw-r--r-- | contrib/librdns/resolver.c | 8 |
3 files changed, 8 insertions, 4 deletions
diff --git a/contrib/librdns/dns_private.h b/contrib/librdns/dns_private.h index a82ebd62e..8200bf038 100644 --- a/contrib/librdns/dns_private.h +++ b/contrib/librdns/dns_private.h @@ -112,12 +112,13 @@ struct rdns_io_channel { }; struct rdns_fake_reply_idx { - enum dns_rcode rcode; + enum rdns_request_type type; unsigned len; char request[0]; }; struct rdns_fake_reply { + enum dns_rcode rcode; struct rdns_reply_entry *result; UT_hash_handle hh; struct rdns_fake_reply_idx key; diff --git a/contrib/librdns/rdns.h b/contrib/librdns/rdns.h index cd4094d45..7ace6e5cd 100644 --- a/contrib/librdns/rdns.h +++ b/contrib/librdns/rdns.h @@ -334,6 +334,7 @@ void rdns_resolver_register_plugin (struct rdns_resolver *resolver, */ void rdns_resolver_set_fake_reply (struct rdns_resolver *resolver, const char *name, + enum rdns_request_type type, enum dns_rcode rcode, struct rdns_reply_entry *reply); diff --git a/contrib/librdns/resolver.c b/contrib/librdns/resolver.c index f3eaa44d9..b3f698fdf 100644 --- a/contrib/librdns/resolver.c +++ b/contrib/librdns/resolver.c @@ -597,7 +597,7 @@ rdns_make_request_full ( 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); - idx->rcode = type; + idx->type = type; idx->len = clen; memcpy (idx->request, cur_name, clen); HASH_FIND (hh, resolver->fake_elts, idx, sizeof (*idx) + clen, @@ -605,7 +605,7 @@ rdns_make_request_full ( if (fake_rep) { /* We actually treat it as a short-circuit */ - req->reply = rdns_make_reply (req, idx->rcode); + req->reply = rdns_make_reply (req, fake_rep->rcode); req->reply->entries = fake_rep->result; req->state = RDNS_REQUEST_FAKE; } @@ -943,6 +943,7 @@ rdns_resolver_set_dnssec (struct rdns_resolver *resolver, bool enabled) void rdns_resolver_set_fake_reply (struct rdns_resolver *resolver, const char *name, + enum rdns_request_type type, enum dns_rcode rcode, struct rdns_reply_entry *reply) { @@ -953,13 +954,14 @@ void rdns_resolver_set_fake_reply (struct rdns_resolver *resolver, assert (len < MAX_FAKE_NAME); srch = malloc (sizeof (*srch) + len); srch->len = len; - srch->rcode = rcode; + srch->type = type; memcpy (srch->request, name, len); HASH_FIND (hh, resolver->fake_elts, srch, len + sizeof (*srch), fake_rep); if (fake_rep) { /* Append reply to the existing list */ + fake_rep->rcode = rcode; DL_APPEND (fake_rep->result, reply); } else { |