]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
ixfrutils: Check the return value of rename()
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 29 May 2019 13:02:13 +0000 (15:02 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 29 May 2019 13:37:47 +0000 (15:37 +0200)
Reported by Coverity (CID 1401680).

pdns/ixfrutils.cc

index 9ff93bbabf397eada632cc6b6f0ee467bb3819f3..cd5f7155c6e4229e031862dec96a0a5bc4e449dd 100644 (file)
@@ -136,7 +136,9 @@ void writeZoneToDisk(const records_t& records, const DNSName& zone, const std::s
   writeRecords(fp, soarecord);
 
   fclose(fp);
-  rename( (fname+".partial").c_str(), fname.c_str());
+  if (rename( (fname+".partial").c_str(), fname.c_str()) != 0) {
+    throw std::runtime_error("Unable to move the zone file for " + zone.toLogString() + " from " + fname + ".partial to " + fname + ": " + string(strerror(errno)));
+  }
 }
 
 void loadZoneFromDisk(records_t& records, const string& fname, const DNSName& zone)