size check + include guard

This commit is contained in:
Robin Müller 2020-11-03 15:45:04 +01:00
parent b71ccf8dd8
commit 38b5695a10
2 changed files with 13 additions and 4 deletions

View File

@ -81,6 +81,10 @@ ReturnValue_t LocalPoolDataSetBase::serializeWithValidityBuffer(uint8_t **buffer
return result;
}
}
if(*size + validityMaskSize > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT;
}
// copy validity buffer to end
std::memcpy(*buffer, validityMask, validityMaskSize);
*size += validityMaskSize;
@ -98,9 +102,13 @@ ReturnValue_t LocalPoolDataSetBase::deSerializeWithValidityBuffer(
return result;
}
}
if(*size < std::ceil(static_cast<float>(fillCount) / 8.0)) {
return SerializeIF::STREAM_TOO_SHORT;
}
uint8_t validBufferIndex = 0;
uint8_t validBufferIndexBit = 0;
// could be made more efficient but make it work first
for (uint16_t count = 0; count < fillCount; count++) {
// set validity buffer here.
bool nextVarValid = this->bitGetter(*buffer +
@ -117,6 +125,7 @@ ReturnValue_t LocalPoolDataSetBase::deSerializeWithValidityBuffer(
}
return result;
}
ReturnValue_t LocalPoolDataSetBase::unlockDataPool() {
MutexIF* mutex = hkManager->getMutexHandle();
return mutex->unlockMutex();

View File

@ -1,5 +1,5 @@
#ifndef FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
#define FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
#define FSFW_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
#include "../serialize/SerialBufferAdapter.h"
#include "../serialize/SerialLinkedListAdapter.h"
@ -70,4 +70,4 @@ private:
#endif /* FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_ */
#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_ */