amazing size checks

This commit is contained in:
Robin Müller 2020-11-03 23:29:03 +01:00
parent f72ee0b7ac
commit e99cf32bdd

View File

@ -59,6 +59,10 @@ public:
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) override { SerializeIF::Endianness streamEndianness) override {
if(*size < timeStampSize) {
return SerializeIF::STREAM_TOO_SHORT;
}
if(timeStamp != nullptr) { if(timeStamp != nullptr) {
/* Endianness will always be MACHINE, so we can simply use memcpy /* Endianness will always be MACHINE, so we can simply use memcpy
here. */ here. */
@ -70,6 +74,10 @@ public:
if(updateData == nullptr) { if(updateData == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
if(*size < updateData->getSerializedSize()) {
return SerializeIF::STREAM_TOO_SHORT;
}
return updateData->deSerialize(buffer, size, streamEndianness); return updateData->deSerialize(buffer, size, streamEndianness);
} }