From: Francis Dupont Date: Sat, 27 Jun 2015 11:20:22 +0000 (+0200) Subject: [3920] Applied proposed cleanup of Pkt{,4} buf/len constructor X-Git-Tag: trac3915a_base X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65c611f2817ec98c230520b7eba6c4c2d51c34e7;p=thirdparty%2Fkea.git [3920] Applied proposed cleanup of Pkt{,4} buf/len constructor --- diff --git a/src/lib/dhcp/pkt.cc b/src/lib/dhcp/pkt.cc index 82e5319c39..dfd1f8aa33 100644 --- a/src/lib/dhcp/pkt.cc +++ b/src/lib/dhcp/pkt.cc @@ -48,8 +48,12 @@ Pkt::Pkt(const uint8_t* buf, uint32_t len, const isc::asiolink::IOAddress& local remote_port_(remote_port), buffer_out_(0) { - data_.resize(len); - if (len) { + + if (len != 0) { + if (buf == NULL) { + isc_throw(InvalidParameter, "data buffer passed to Pkt is NULL"); + } + data_.resize(len); memcpy(&data_[0], buf, len); } } diff --git a/src/lib/dhcp/pkt4.cc b/src/lib/dhcp/pkt4.cc index c56c166959..1a406f87c9 100644 --- a/src/lib/dhcp/pkt4.cc +++ b/src/lib/dhcp/pkt4.cc @@ -74,9 +74,6 @@ Pkt4::Pkt4(const uint8_t* data, size_t len) isc_throw(OutOfRange, "Truncated DHCPv4 packet (len=" << len << ") received, at least " << DHCPV4_PKT_HDR_LEN << " is expected."); - - } else if (data == NULL) { - isc_throw(InvalidParameter, "data buffer passed to Pkt4 is NULL"); } }