From: Remi Gacogne Date: Wed, 29 May 2019 13:02:13 +0000 (+0200) Subject: ixfrutils: Check the return value of rename() X-Git-Tag: dnsdist-1.4.0-beta1~8^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c15074f0aecb87cc902ee047144f698584af1162;p=thirdparty%2Fpdns.git ixfrutils: Check the return value of rename() Reported by Coverity (CID 1401680). --- diff --git a/pdns/ixfrutils.cc b/pdns/ixfrutils.cc index 9ff93bbabf..cd5f7155c6 100644 --- a/pdns/ixfrutils.cc +++ b/pdns/ixfrutils.cc @@ -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)