From 497f9472373fe3883419c6d0c5f6a9dce9e1e38a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 14 Sep 2023 15:04:54 +0200 Subject: [PATCH] add missing 0 termination --- src/fsfw/cfdp/handler/SourceHandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fsfw/cfdp/handler/SourceHandler.cpp b/src/fsfw/cfdp/handler/SourceHandler.cpp index 141afcef..eba21b7d 100644 --- a/src/fsfw/cfdp/handler/SourceHandler.cpp +++ b/src/fsfw/cfdp/handler/SourceHandler.cpp @@ -169,6 +169,10 @@ ReturnValue_t cfdp::SourceHandler::transactionStart(PutRequest& putRequest, Remo const char* destNamePtr = putRequest.getDestName().getCString(transactionParams.destNameSize); std::strncpy(transactionParams.sourceName.data(), srcNamePtr, transactionParams.sourceNameSize); std::strncpy(transactionParams.destName.data(), destNamePtr, transactionParams.destNameSize); + // Add 0 termination. The source and dest name size can not be larger than UINT8_MAX, so this + // operation is safe. + transactionParams.sourceName[transactionParams.sourceNameSize] = '\0'; + transactionParams.destName[transactionParams.destNameSize] = '\0'; FilesystemParams params(transactionParams.sourceName.data()); if (!sourceParams.user.vfs.fileExists(params)) { return FILE_DOES_NOT_EXIST;