1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Used a better strategy in DNSResourceRecord's constructor from buffer which will parse the data even if contains_dname returns false.

This commit is contained in:
Matias Fontanini
2012-11-20 18:31:33 -03:00
parent 7e080cf1ab
commit f3ea99e0b0

View File

@@ -84,12 +84,10 @@ DNSResourceRecord::DNSResourceRecord(const uint8_t *buffer, uint32_t size)
buffer += sizeof(uint16_t);
if(buffer + data.size() > buffer_end)
throw std::runtime_error("Not enough size for resource data");
if(contains_dname(info_.type))
if(contains_dname(info_.type) || data.size() != sizeof(uint32_t))
std::copy(buffer, buffer + data.size(), data.begin());
else if(data.size() == sizeof(uint32_t))
*(uint32_t*)&data[0] = *(uint32_t*)buffer;
else
throw std::runtime_error("Not enough size for resource data");
impl = tmp_impl.release();
}