summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv/csv_lease_file4.cc
diff options
context:
space:
mode:
authorMarcin Siodelski <marcin@isc.org>2018-12-03 15:48:41 +0100
committerMarcin Siodelski <marcin@isc.org>2018-12-05 19:33:28 +0100
commit2408adc54888165c7aaae2a7d1b6b507a517893c (patch)
tree4febc017e5adc8d71711aa5d1531096a2b61bc2e /src/lib/dhcpsrv/csv_lease_file4.cc
parentUpdate install.xml (diff)
downloadkea-2408adc54888165c7aaae2a7d1b6b507a517893c.tar.xz
kea-2408adc54888165c7aaae2a7d1b6b507a517893c.zip
[#303,!151] Solved a problem with reading leases having long lifetimes.
Reading leases having long, e.g. infinite, lifetimes from a lease file used to fail due to invalid cast to uint32_t.
Diffstat (limited to 'src/lib/dhcpsrv/csv_lease_file4.cc')
-rw-r--r--src/lib/dhcpsrv/csv_lease_file4.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/dhcpsrv/csv_lease_file4.cc b/src/lib/dhcpsrv/csv_lease_file4.cc
index e54189f144..e9ca5a76a6 100644
--- a/src/lib/dhcpsrv/csv_lease_file4.cc
+++ b/src/lib/dhcpsrv/csv_lease_file4.cc
@@ -6,6 +6,7 @@
#include <config.h>
#include <dhcpsrv/csv_lease_file4.h>
+#include <ctime>
using namespace isc::asiolink;
using namespace isc::data;
@@ -47,7 +48,7 @@ CSVLeaseFile4::append(const Lease4& lease) {
row.writeAt(getColumnIndex("client_id"), lease.client_id_->toText());
}
row.writeAt(getColumnIndex("valid_lifetime"), lease.valid_lft_);
- row.writeAt(getColumnIndex("expire"), lease.cltt_ + lease.valid_lft_);
+ row.writeAt(getColumnIndex("expire"), static_cast<uint64_t>(lease.cltt_ + lease.valid_lft_));
row.writeAt(getColumnIndex("subnet_id"), lease.subnet_id_);
row.writeAt(getColumnIndex("fqdn_fwd"), lease.fqdn_fwd_);
row.writeAt(getColumnIndex("fqdn_rev"), lease.fqdn_rev_);
@@ -194,8 +195,9 @@ CSVLeaseFile4::readValid(const CSVRow& row) {
time_t
CSVLeaseFile4::readCltt(const CSVRow& row) {
- uint32_t cltt = row.readAndConvertAt<uint32_t>(getColumnIndex("expire"))
- - readValid(row);
+ time_t cltt =
+ static_cast<time_t>(row.readAndConvertAt<uint64_t>(getColumnIndex("expire"))
+ - readValid(row));
return (cltt);
}