mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-02 06:55:16 +00:00
[1470] Added checks for zero length data
This commit is contained in:
@@ -112,7 +112,9 @@ Generic::Generic(isc::util::InputBuffer& buffer, size_t rdata_len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vector<uint8_t> data(rdata_len);
|
vector<uint8_t> data(rdata_len);
|
||||||
|
if (rdata_len > 0) {
|
||||||
buffer.readData(&data[0], rdata_len);
|
buffer.readData(&data[0], rdata_len);
|
||||||
|
}
|
||||||
|
|
||||||
impl_ = new GenericImpl(data);
|
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;
|
size_t len = (this_len < other_len) ? this_len : other_len;
|
||||||
int cmp;
|
int cmp;
|
||||||
|
|
||||||
if ((cmp = memcmp(&lhs.data_[0], &rhs.data_[0], len))
|
// TODO: is there a need to check len - should we just assert?
|
||||||
!= 0) {
|
// (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);
|
return (cmp);
|
||||||
} else {
|
} else {
|
||||||
return ((this_len == other_len) ? 0 :
|
return ((this_len == other_len) ? 0 :
|
||||||
|
Reference in New Issue
Block a user