Commit 7cdae45e authored by Marcin Siodelski's avatar Marcin Siodelski

[2549] Check address type in some option pack() methods.

parent 6b7ef74b
......@@ -72,6 +72,12 @@ void Option6AddrLst::pack(isc::util::OutputBuffer& buf) {
for (AddressContainer::const_iterator addr=addrs_.begin();
addr!=addrs_.end(); ++addr) {
if (!addr->isV6()) {
isc_throw(isc::BadValue, addr->toText()
<< " is not an IPv6 address");
}
// If an address is IPv6 address it should have assumed
// length of V6ADDRESS_LEN.
buf.writeData(&addr->toBytes()[0], V6ADDRESS_LEN);
}
}
......@@ -104,8 +110,7 @@ std::string Option6AddrLst::toText(int indent /* =0 */) {
}
uint16_t Option6AddrLst::len() {
return (OPTION6_HDR_LEN + addrs_.size()*V6ADDRESS_LEN);
return (OPTION6_HDR_LEN + addrs_.size() * V6ADDRESS_LEN);
}
} // end of namespace isc::dhcp
......
......@@ -51,7 +51,10 @@ void Option6IAAddr::pack(isc::util::OutputBuffer& buf) {
// length without 4-byte option header
buf.writeUint16(len() - getHeaderLen());
if (!addr_.isV6()) {
isc_throw(isc::BadValue, addr_.toText()
<< " is not an IPv6 address");
}
buf.writeData(&addr_.toBytes()[0], isc::asiolink::V6ADDRESS_LEN);
buf.writeUint32(preferred_);
......
......@@ -168,7 +168,7 @@ namespace isc {
namespace dhcp {
isc::asiolink::IOAddress firstAddrInPrefix(const isc::asiolink::IOAddress& prefix,
uint8_t len) {
uint8_t len) {
if (prefix.isV4()) {
return (firstAddrInPrefix4(prefix, len));
......
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