]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
nts: fix destroying of NTS-KE client
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 27 Jul 2020 10:13:39 +0000 (12:13 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 28 Jul 2020 10:48:23 +0000 (12:48 +0200)
Destroy the NTS-KE session of the client immediately even when the
resolver of the NTP address is running. This removes the session
local change handler and avoids an assertion failure in the local
finalization.

nts_ke_client.c

index 5cf1f8ebc3074da9157eb4c13a44a60a99b66828..604bbc5b78fa3e37ee9f1721b0d55a883a2a5902 100644 (file)
@@ -72,7 +72,7 @@ name_resolve_handler(DNS_Status status, int n_addrs, IPAddr *ip_addrs, void *arg
   inst->resolving_name = 0;
 
   if (inst->destroying) {
-    NKC_DestroyInstance(inst);
+    Free(inst);
     return;
   }
 
@@ -292,22 +292,24 @@ NKC_CreateInstance(IPSockAddr *address, const char *name)
 void
 NKC_DestroyInstance(NKC_Instance inst)
 {
-  /* If the resolver is running, destroy the instance later when finished */
-  if (inst->resolving_name) {
-    inst->destroying = 1;
-    return;
-  }
-
   NKSN_DestroyInstance(inst->session);
 
   Free(inst->name);
-  Free(inst);
 
   client_credentials_refs--;
   if (client_credentials_refs <= 0 && client_credentials) {
     NKSN_DestroyCertCredentials(client_credentials);
     client_credentials = NULL;
   }
+
+  /* If the asynchronous resolver is running, let the handler free
+     the instance later */
+  if (inst->resolving_name) {
+    inst->destroying = 1;
+    return;
+  }
+
+  Free(inst);
 }
 
 /* ================================================== */