]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dns: dns_lookup*() - Assert that at least one IP is returned on success
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 1 Apr 2022 10:10:22 +0000 (13:10 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Mon, 25 Apr 2022 09:07:11 +0000 (09:07 +0000)
src/lib-dns/dns-lookup.c
src/lib-dns/dns-lookup.h

index 0cb56325cd491ba91a4b60e81b2624ee6c111b11..393015f2122fb571f4b744a7e4c22bab33dcd785 100644 (file)
@@ -306,6 +306,7 @@ static void dns_lookup_callback(struct dns_lookup *lookup)
                e->add_str("cached", lookup->cached ? "yes" : "no");
                e_debug(e->event(), "Lookup successful after %u msecs",
                        lookup->result.msecs);
+               i_assert(lookup->ptr_lookup || lookup->result.ips_count > 0);
        }
        lookup->callback(&lookup->result, lookup->context);
 }
index 549bc9f0539b4cc6e6dc21bc6485cd947d798cb1..7df1786758eef7f223d5d04fd8f07eea304a84a2 100644 (file)
@@ -30,7 +30,7 @@ struct dns_lookup_result {
        unsigned int msecs;
 
        /* for IP lookup: */
-       unsigned int ips_count;
+       unsigned int ips_count; /* guaranteed to be >0 on success */
        const struct ip_addr *ips;
        /* for PTR lookup: */
        const char *name;