the joys of UB or whatever that crap was

This commit is contained in:
2023-08-14 12:13:29 +02:00
parent 7aeb25e064
commit 15629abf19
4 changed files with 21 additions and 5 deletions

View File

@ -197,8 +197,8 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
TmTcMessage tmtcMessage;
const uint8_t* pduPtr;
FileDataInfo fdInfo;
auto accessor = onePduSentCheck(fsmResult, tmtcMessage, &pduPtr);
{
auto accessor = onePduSentCheck(fsmResult, tmtcMessage, &pduPtr);
FileDataReader fdReader(pduPtr, accessor.second.size(), fdInfo);
// 10 byte PDU header, 4 byte offset, 255 byte file data
CHECK(accessor.second.size() == 269);
@ -216,7 +216,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
// Check second file data PDU.
fsmResult = sourceHandler.stateMachine();
accessor = onePduSentCheck(fsmResult, tmtcMessage, &pduPtr);
auto accessor = onePduSentCheck(fsmResult, tmtcMessage, &pduPtr);
FileDataReader fdReader(pduPtr, accessor.second.size(), fdInfo);
// 10 byte PDU header, 4 byte offset, remaining file data (400 - 255 == 145).
CHECK(accessor.second.size() == 10 + 4 + largerFileData.size() - MAX_FILE_SEGMENT_SIZE);

View File

@ -39,7 +39,8 @@ ReturnValue_t FilesystemMock::readFromFile(FileOpParams params, uint8_t **buffer
if (readSize + readLen > maxSize) {
return SerializeIF::STREAM_TOO_SHORT;
}
std::copy(info.fileRaw.data() + params.offset, info.fileRaw.data() + readLen, *buffer);
std::copy(info.fileRaw.data() + params.offset, info.fileRaw.data() + params.offset + readLen,
*buffer);
*buffer += readLen;
readSize += readLen;
}