From a87859f1fa05ce92e99acb2c12aae0245bc8e79e Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Thu, 2 Mar 2023 10:18:11 +0000 Subject: [PATCH] catz: protect db_registered and db callback (un)registration with a lock Doing this to avoid a race between the 'dns__catz_update_cb()' and 'dns_catz_dbupdate_callback()' functions. --- lib/dns/catz.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/dns/catz.c b/lib/dns/catz.c index 60f690fbe1..f0f3d04771 100644 --- a/lib/dns/catz.c +++ b/lib/dns/catz.c @@ -2480,6 +2480,7 @@ final: * update callback in zone_startload or axfr_makedb, but we will * call onupdate() artificially so we can register the callback here. */ + LOCK(&catzs->lock); if (!oldcatz->db_registered) { result = dns_db_updatenotify_register( updb, dns_catz_dbupdate_callback, oldcatz->catzs); @@ -2487,6 +2488,7 @@ final: oldcatz->db_registered = true; } } + UNLOCK(&catzs->lock); exit: catz->updateresult = result;