Fix segfault when time_t is 64bit on 32bit arch (#1666)

On some platforms, like with musl libc, time_t may be 64 bit even on
32bit platforms. Fix segfault by convert time_t to 64 bit and use 64bit
format modifier instead of assume time_t is %ld
pull/1682/head^2
Natanael Copa 2020-08-07 15:59:49 +02:00 committed by Tatsuhiro Tsujikawa
parent 15cad965eb
commit 2d0171e956
1 changed files with 4 additions and 3 deletions

View File

@ -183,11 +183,12 @@ bool ServerStat::operator==(const ServerStat& serverStat) const
std::string ServerStat::toString() const std::string ServerStat::toString() const
{ {
return fmt("host=%s, protocol=%s, dl_speed=%d, sc_avg_speed=%d," return fmt("host=%s, protocol=%s, dl_speed=%d, sc_avg_speed=%d,"
" mc_avg_speed=%d, last_updated=%ld, counter=%d, status=%s", " mc_avg_speed=%d, last_updated=%" PRId64
", counter=%d, status=%s",
getHostname().c_str(), getProtocol().c_str(), getDownloadSpeed(), getHostname().c_str(), getProtocol().c_str(), getDownloadSpeed(),
getSingleConnectionAvgSpeed(), getMultiConnectionAvgSpeed(), getSingleConnectionAvgSpeed(), getMultiConnectionAvgSpeed(),
getLastUpdated().getTimeFromEpoch(), getCounter(), static_cast<int64_t>(getLastUpdated().getTimeFromEpoch()),
STATUS_STRING[getStatus()]); getCounter(), STATUS_STRING[getStatus()]);
} }
} // namespace aria2 } // namespace aria2