Skip to content

Commit

Permalink
Fix coverity time_t related warnings
Browse files Browse the repository at this point in the history
Most are not *really* bad, as we convert tmioe_t or unsigned int, which is good
for quite some time. One case of converting time_t to *signed* int spotted.
  • Loading branch information
omoerbeek committed Jun 22, 2023
1 parent 5079639 commit 5a7a3b6
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/bindbackend/bindbackend2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ void Bind2Backend::getUnfreshSlaveInfos(vector<DomainInfo>* unfreshDomains)
catch (...) {
}
sd.serial = soadata.serial;
// coverity[store_truncates_time_t]
if (sd.last_check + soadata.refresh < (unsigned int)time(nullptr))
unfreshDomains->push_back(std::move(sd));
}
Expand Down
1 change: 1 addition & 0 deletions pdns/auth-zonecache.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public:

uint32_t getRefreshInterval() const
{
// coverity[store_truncates_time_t]
return d_refreshinterval;
}

Expand Down
1 change: 1 addition & 0 deletions pdns/dbdnsseckeeper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ DNSSECKeeper::keyset_t DNSSECKeeper::getEntryPoints(const DNSName& zname)
DNSSECKeeper::keyset_t DNSSECKeeper::getKeys(const DNSName& zone, bool useCache)
{
static int ttl = ::arg().asNum("dnssec-key-cache-ttl");
// coverity[store_truncates_time_t]
unsigned int now = time(nullptr);

if(!((++s_ops) % 100000)) {
Expand Down
2 changes: 1 addition & 1 deletion pdns/ixplore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ int main(int argc, char** argv) {
shared_ptr<const SOARecordContent> sr;
uint32_t serial = getSerialFromMaster(master, zone, sr, tt);
if(ourSerial == serial) {
time_t sleepTime = sr ? sr->d_st.refresh : 60;
unsigned int sleepTime = sr ? sr->d_st.refresh : 60;
cout<<"still up to date, their serial is "<<serial<<", sleeping "<<sleepTime<<" seconds"<<endl;
sleep(sleepTime);
continue;
Expand Down
1 change: 1 addition & 0 deletions pdns/saxfr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ try
DNSPacketWriter pwtkey(packet, gssctx.getLabel(), QType::TKEY, QClass::ANY);
TKEYRecordContent tkrc;
tkrc.d_algo = DNSName("gss-tsig.");
// coverity[store_truncates_time_t]
tkrc.d_inception = time((time_t*)NULL);
tkrc.d_expiration = tkrc.d_inception+15;
tkrc.d_mode = 3;
Expand Down
2 changes: 2 additions & 0 deletions pdns/serialtweaker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ uint32_t calculateEditSOA(uint32_t old_serial, const string& kind, const DNSName
return (old_serial + (inception / (7*86400)));
}
else if(pdns_iequals(kind,"EPOCH")) {
// coverity[store_truncates_time_t]
return time(nullptr);
}
else if(pdns_iequals(kind,"INCEPTION-EPOCH")) {
Expand Down Expand Up @@ -107,6 +108,7 @@ static uint32_t calculateIncreaseSOA(uint32_t old_serial, const string& increase
return old_serial + 1;
}
else if (pdns_iequals(increaseKind, "EPOCH")) {
// coverity[store_truncates_time_t]
return time(nullptr);
}
else if (pdns_iequals(increaseKind, "DEFAULT")) {
Expand Down
1 change: 1 addition & 0 deletions pdns/tkey.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void PacketHandler::tkeyHandler(const DNSPacket& p, std::unique_ptr<DNSPacket>&
tkey_out->d_error = 0;
tkey_out->d_mode = tkey_in.d_mode;
tkey_out->d_algo = tkey_in.d_algo;
// coverity[store_truncates_time_t]
tkey_out->d_inception = inception;
tkey_out->d_expiration = tkey_out->d_inception+15;

Expand Down
1 change: 1 addition & 0 deletions pdns/ws-auth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ static void gatherComments(const Json& container, const DNSName& qname, const QT

time_t now = time(nullptr);
for (const auto& comment : container["comments"].array_items()) {
// FIXME this is converting to a *signed* int, 2036 issue
c.modified_at = intFromJson(comment, "modified_at", now);
c.content = stringFromJson(comment, "content");
c.account = stringFromJson(comment, "account");
Expand Down

0 comments on commit 5a7a3b6

Please sign in to comment.