Commit ef00fabe authored by Jelte Jansen's avatar Jelte Jansen
Browse files

fix for negative TTL that gets parsed on newer versions of gcc/stdc++


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/parkinglot@718 e5f2f494-b856-4b98-b285-d166d9295462
parent d698c8b1
...@@ -31,12 +31,15 @@ namespace dns { ...@@ -31,12 +31,15 @@ namespace dns {
RRTTL::RRTTL(const string& ttlstr) RRTTL::RRTTL(const string& ttlstr)
{ {
uint32_t val; // Some systems (at least gcc-4.4) flow negative values over into
// unsigned integer, where older systems failed to parse. We want
// that failure here, so we extract into int64 and check the value
uint64_t val;
istringstream iss(ttlstr); istringstream iss(ttlstr);
iss >> dec >> val; iss >> dec >> val;
if (iss.rdstate() == ios::eofbit) { if (iss.rdstate() == ios::eofbit && val >= 0 && val <= 0xffffffff) {
ttlval_ = val; ttlval_ = static_cast<uint32_t>(val);
} else { } else {
dns_throw(InvalidRRTTL, "invalid TTL"); dns_throw(InvalidRRTTL, "invalid TTL");
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment