]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix hash lookup
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Jun 2018 14:43:22 +0000 (15:43 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Jun 2018 14:43:22 +0000 (15:43 +0100)
contrib/librdns/dns_private.h
contrib/librdns/rdns.h
contrib/librdns/resolver.c

index a82ebd62e25a07f2248f85bbcc6abbaf5bf365bd..8200bf038ed26257e9a1893c17907abf05f6ee16 100644 (file)
@@ -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;
index cd4094d45d590ddd9034c2186b7d218181afd272..7ace6e5cdebc126dd60e4ce4d9f41f0ea46e52e5 100644 (file)
@@ -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);
 
index f3eaa44d96e0a551e695ce85e2aadfd51be064a7..b3f698fdf814e6d0d6aded8bb986c09484ca75d3 100644 (file)
@@ -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 {