From e10d80f9e4772cbea54ef5055677c48ff2806883 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 29 May 2019 12:26:04 +0200 Subject: [PATCH] auth: Properly initialize a new BindBackend domain (kind, ctime) Reported by Coverity (CID 1401635). --- modules/bindbackend/bindbackend2.cc | 4 ++++ modules/bindbackend/bindbackend2.hh | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/bindbackend/bindbackend2.cc b/modules/bindbackend/bindbackend2.cc index 69d0450fc9..f513addfbc 100644 --- a/modules/bindbackend/bindbackend2.cc +++ b/modules/bindbackend/bindbackend2.cc @@ -603,6 +603,7 @@ string Bind2Backend::DLAddDomainHandler(const vector&parts, Utility::pid bbd.d_loaded=true; bbd.d_lastcheck=0; bbd.d_status="parsing into memory"; + bbd.setCtime(); safePutBBDomainInfo(bbd); @@ -1262,11 +1263,13 @@ BB2DomainInfo Bind2Backend::createDomainEntry(const DNSName& domain, const strin } BB2DomainInfo bbd; + bbd.d_kind = DomainInfo::Native; bbd.d_id = newid; bbd.d_records = shared_ptr(new recordstorage_t); bbd.d_name = domain; bbd.setCheckInterval(getArgAsNum("check-interval")); bbd.d_filename = filename; + return bbd; } @@ -1300,6 +1303,7 @@ bool Bind2Backend::createSlaveDomain(const string &ip, const DNSName& domain, co BB2DomainInfo bbd = createDomainEntry(domain, filename); bbd.d_kind = DomainInfo::Slave; bbd.d_masters.push_back(ComboAddress(ip, 53)); + bbd.setCtime(); safePutBBDomainInfo(bbd); return true; } diff --git a/modules/bindbackend/bindbackend2.hh b/modules/bindbackend/bindbackend2.hh index 424c5683b0..ee545d6365 100644 --- a/modules/bindbackend/bindbackend2.hh +++ b/modules/bindbackend/bindbackend2.hh @@ -165,9 +165,9 @@ public: vector d_masters; //!< IP address of the master of this domain set d_also_notify; //!< IP list of hosts to also notify LookButDontTouch d_records; //!< the actual records belonging to this domain - time_t d_ctime; //!< last known ctime of the file on disk - time_t d_lastcheck; //!< last time domain was checked for freshness - uint32_t d_lastnotified; //!< Last serial number we notified our slaves of + time_t d_ctime{0}; //!< last known ctime of the file on disk + time_t d_lastcheck{0}; //!< last time domain was checked for freshness + uint32_t d_lastnotified{0}; //!< Last serial number we notified our slaves of unsigned int d_id; //!< internal id of the domain mutable bool d_checknow; //!< if this domain has been flagged for a check bool d_loaded; //!< if a domain is loaded -- 2.47.2