A new resolver can be created while we currently run a check with the
authorflorian <florian@openbsd.org>
Thu, 28 Jan 2021 07:34:34 +0000 (07:34 +0000)
committerflorian <florian@openbsd.org>
Thu, 28 Jan 2021 07:34:34 +0000 (07:34 +0000)
old configuration. We will then request another check that runs in
parallel to the old check. If the new check finishes earlier, the
current check result will be overwritten by an outdated check result
which is likely wrong.
While here fix some whitespace.
OK phessler

sbin/unwind/resolver.c

index 49f51d8..feeb6c2 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: resolver.c,v 1.137 2021/01/27 08:30:50 florian Exp $  */
+/*     $OpenBSD: resolver.c,v 1.138 2021/01/28 07:34:34 florian Exp $  */
 
 /*
  * Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -1513,8 +1513,6 @@ check_resolver(struct uw_resolver *resolver_to_check)
                evtimer_add(&resolver_to_check->check_ev,
                    &resolver_to_check->check_tv);
        }
-
-
 }
 
 void
@@ -1529,6 +1527,12 @@ check_resolver_done(struct uw_resolver *res, void *arg, int rcode,
 
        checked_resolver->check_running--;
 
+       if (checked_resolver != resolvers[checked_resolver->type]) {
+               log_debug("%s: %s: ignoring late check result", __func__,
+                   uw_resolver_type_str[checked_resolver->type]);
+               goto out;
+       }
+
        prev_state = checked_resolver->state;
 
        if (answer_len < LDNS_HEADER_SIZE) {