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:// e5f2f494-b856-4b98-b285-d166d9295462
parent d698c8b1
......@@ -31,12 +31,15 @@ namespace dns {
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);
iss >> dec >> val;
if (iss.rdstate() == ios::eofbit) {
ttlval_ = val;
if (iss.rdstate() == ios::eofbit && val >= 0 && val <= 0xffffffff) {
ttlval_ = static_cast<uint32_t>(val);
} else {
dns_throw(InvalidRRTTL, "invalid TTL");
Supports Markdown
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