2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 21:45:37 +00:00

[1470] Added checks for zero length data

This commit is contained in:
Stephen Morris
2011-12-12 19:37:13 +00:00
parent 0a5f810dd8
commit f15d883138

View File

@@ -112,7 +112,9 @@ Generic::Generic(isc::util::InputBuffer& buffer, size_t rdata_len) {
}
vector<uint8_t> data(rdata_len);
buffer.readData(&data[0], rdata_len);
if (rdata_len > 0) {
buffer.readData(&data[0], rdata_len);
}
impl_ = new GenericImpl(data);
}
@@ -242,8 +244,10 @@ compare_internal(const GenericImpl& lhs, const GenericImpl& rhs) {
size_t len = (this_len < other_len) ? this_len : other_len;
int cmp;
if ((cmp = memcmp(&lhs.data_[0], &rhs.data_[0], len))
!= 0) {
// TODO: is there a need to check len - should we just assert?
// (Depends if it is possible for rdata to have zero length)
if ((len != 0) &&
((cmp = memcmp(&lhs.data_[0], &rhs.data_[0], len)) != 0)) {
return (cmp);
} else {
return ((this_len == other_len) ? 0 :