From c674c947b9298d0e3f4c27977d292d9bb92c8c75 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9gory=20Oestreicher?= Date: Fri, 15 Mar 2013 12:53:23 +0000 Subject: [PATCH] Prevent potential side effects and use local variables here --- src/ldapbackend.cc | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/ldapbackend.cc b/src/ldapbackend.cc index be1f08a..e830788 100644 --- a/src/ldapbackend.cc +++ b/src/ldapbackend.cc @@ -692,6 +692,8 @@ bool LdapBackend::getDomainInfo( const string& domain, DomainInfo& di ) { string filter; SOAData sd; + int msgid; + PowerLDAP::sentry_t result; const char* attronly[] = { "sOARecord", "PdnsDomainId", @@ -707,7 +709,7 @@ bool LdapBackend::getDomainInfo( const string& domain, DomainInfo& di ) // search for SOARecord of domain filter = "(&(associatedDomain=" + toLower( m_pldap->escape( domain ) ) + ")(SOARecord=*))"; m_msgid = m_pldap->search( getArg( "basedn" ), LDAP_SCOPE_SUBTREE, filter, attronly ); - m_pldap->getSearchEntry( m_msgid, m_result ); + m_pldap->getSearchEntry( msgid, result ); } catch( LDAPTimeout < ) { @@ -732,34 +734,34 @@ bool LdapBackend::getDomainInfo( const string& domain, DomainInfo& di ) throw( DBException( "STL exception" ) ); } - if( m_result.count( "sOARecord" ) && !m_result["sOARecord"].empty() ) + if( result.count( "sOARecord" ) && !result["sOARecord"].empty() ) { sd.serial = 0; - fillSOAData( m_result["sOARecord"][0], sd ); + fillSOAData( result["sOARecord"][0], sd ); - if ( m_result.count( "PdnsDomainId" ) && !m_result["PdnsDomainId"].empty() ) - di.id = boost::lexical_cast( m_result["PdnsDomainId"][0] ); + if ( result.count( "PdnsDomainId" ) && !result["PdnsDomainId"].empty() ) + di.id = boost::lexical_cast( result["PdnsDomainId"][0] ); else di.id = 0; di.serial = sd.serial; di.zone = domain; - if( m_result.count( "PdnsDomainLastCheck" ) && !m_result["PdnsDomainLastCheck"].empty() ) - di.last_check = boost::lexical_cast( m_result["PdnsDomainLastCheck"][0] ); + if( result.count( "PdnsDomainLastCheck" ) && !result["PdnsDomainLastCheck"].empty() ) + di.last_check = boost::lexical_cast( result["PdnsDomainLastCheck"][0] ); else di.last_check = 0; - if ( m_result.count( "PdnsDomainNotifiedSerial" ) && !m_result["PdnsDomainNotifiedSerial"].empty() ) - di.notified_serial = boost::lexical_cast( m_result["PdnsDomainNotifiedSerial"][0] ); + if ( result.count( "PdnsDomainNotifiedSerial" ) && !result["PdnsDomainNotifiedSerial"].empty() ) + di.notified_serial = boost::lexical_cast( result["PdnsDomainNotifiedSerial"][0] ); else di.notified_serial = 0; - if ( m_result.count( "PdnsDomainMaster" ) && !m_result["PdnsDomainMaster"].empty() ) - di.masters = m_result["PdnsDomainMaster"]; + if ( result.count( "PdnsDomainMaster" ) && !result["PdnsDomainMaster"].empty() ) + di.masters = result["PdnsDomainMaster"]; - if ( m_result.count( "PdnsDomainType" ) && !m_result["PdnsDomainType"].empty() ) { - string kind = m_result["PdnsDomainType"][0]; + if ( result.count( "PdnsDomainType" ) && !result["PdnsDomainType"].empty() ) { + string kind = result["PdnsDomainType"][0]; if ( kind == "master" ) di.kind = DomainInfo::Master; else if ( kind == "slave" ) -- 2.11.4.GIT