diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index a017ecde..2f48fe2d 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -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 repoAndTargetFileBuffer(remainingSize + 1, 0); std::memcpy(repoAndTargetFileBuffer.data(), data, remainingSize); const char* currentCharPtr = reinterpret_cast(repoAndTargetFileBuffer.data());