that should do the job
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
2024-04-11 10:49:29 +02:00
parent 398e7a3a05
commit 6a0b18ffd0
4 changed files with 22 additions and 4 deletions

View File

@ -850,7 +850,9 @@ class TcSimplexSendFile : public TcBase {
if (result != returnvalue::OK) {
return result;
}
if (chunkParameter == 0) {
/// No chunks makes no sense, and DIV str can not be longer than whats representable with 3
/// decimal digits.
if (chunkParameter == 0 or chunkParameter > 999) {
return INVALID_PARAMETER;
}
std::string fileName(reinterpret_cast<const char*>(*dataPtr));
@ -860,8 +862,8 @@ class TcSimplexSendFile : public TcBase {
size_t currentCopyIdx = 0;
size_t payloadLen = fileName.length() + sizeof(NULL_TERMINATOR) + CRC_SIZE;
if (chunkParameter > 1) {
char divStr[12]{};
sprintf(divStr, "DIV%03d", chunkParameter);
char divStr[16]{};
sprintf(divStr, "DIV%03u", chunkParameter);
std::memcpy(payloadStart, divStr, DIV_STR_LEN);
payloadLen += DIV_STR_LEN;
currentCopyIdx += DIV_STR_LEN;