more documentation

This commit is contained in:
Robin Müller 2021-07-19 20:12:21 +02:00
parent 914336ba66
commit 28470be24f
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -114,11 +114,14 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
switch(actionId) {
case(LIST_DIRECTORY_INTO_FILE): {
// TODO: Packet definition for clean deserialization
// Two bytes for a and R flag, at least 5 bytes for minimum valid path /tmp with
// null termination
if(size < 7) {
// 2 bytes for a and R flag, at least 5 bytes for minimum valid path /tmp with
// null termination, at least 7 bytes for minimum target file name /tmp/a with
// null termination.
if(size < 14) {
return HasActionsIF::INVALID_PARAMETERS;
}
// We could also make -l optional, but I can't think of a reason why to not use -l..
// This flag specifies to run ls with -a
bool aFlag = data[0];
data += 1;
@ -128,7 +131,7 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
size_t remainingSize = size - 2;
// One larger for null termination, which prevents undefined behaviour if the sent
// string is not 0 terminated
// strings are not 0 terminated properly
std::vector<uint8_t> repoAndTargetFileBuffer(remainingSize + 1, 0);
std::memcpy(repoAndTargetFileBuffer.data(), data, remainingSize);
const char* currentCharPtr = reinterpret_cast<const char*>(repoAndTargetFileBuffer.data());