]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: save errno value as close(2) might clobber it 11101/head
authorOtto <otto.moerbeek@open-xchange.com>
Wed, 15 Dec 2021 12:40:20 +0000 (13:40 +0100)
committerOtto <otto.moerbeek@open-xchange.com>
Wed, 15 Dec 2021 12:40:20 +0000 (13:40 +0100)
pdns/nameserver.cc

index ce07abdc7d8f379c038ad03f7f80f410e4b9045f..183033dd6e495574a4a197c0f3f72c1a927bc66c 100644 (file)
@@ -150,13 +150,13 @@ void UDPNameserver::bindAddresses()
         g_localaddresses.push_back(locala);
 
     if(::bind(s, (sockaddr*)&locala, locala.getSocklen()) < 0) {
-      string binderror = stringerror();
+      int err = errno;
       close(s);
-      if( errno == EADDRNOTAVAIL && ! ::arg().mustDo("local-address-nonexist-fail") ) {
+      if (err == EADDRNOTAVAIL && !::arg().mustDo("local-address-nonexist-fail")) {
         g_log<<Logger::Error<<"Address " << locala << " does not exist on this server - skipping UDP bind" << endl;
         continue;
       } else {
-        g_log<<Logger::Error<<"Unable to bind UDP socket to '"+locala.toStringWithPort()+"': "<<binderror<<endl;
+        g_log<<Logger::Error<<"Unable to bind UDP socket to '"+locala.toStringWithPort()+"': "<<stringerror(err)<<endl;
         throw PDNSException("Unable to bind to UDP socket");
       }
     }