From 0bedf4cc836a0463d4cd84aae331c9f0effbd15c Mon Sep 17 00:00:00 2001 From: Isaac Rowe <9010221+irowebbn@users.noreply.github.com> Date: Mon, 12 Jun 2023 11:19:40 -0500 Subject: [PATCH] Fix #111: Use correct length filename for too large test --- unit-test/ds_file_tests.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/unit-test/ds_file_tests.c b/unit-test/ds_file_tests.c index 4fc8469..b8590a5 100644 --- a/unit-test/ds_file_tests.c +++ b/unit-test/ds_file_tests.c @@ -964,8 +964,11 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge(void) /* Set up the handle */ OS_OpenCreate(&DS_AppData.FileStatus[FileIndex].FileHandle, NULL, 0, 0); - strncpy(DS_AppData.FileStatus[FileIndex].FileName, "directory1/filenamefilenamefilenamefilenamefilenamefilename", - sizeof(DS_AppData.FileStatus[FileIndex].FileName)); + const char DirName[] = "directory1/"; + size_t DirNameLen = sizeof(DirName)/sizeof(char); + strncpy(DS_AppData.FileStatus[FileIndex].FileName, DirName, DirNameLen); + memset(&DS_AppData.FileStatus[FileIndex].FileName[DirNameLen-1], 'f', DS_TOTAL_FNAME_BUFSIZE - DirNameLen); + DS_AppData.FileStatus[FileIndex].FileName[DS_TOTAL_FNAME_BUFSIZE-1] = '\0'; strncpy(DS_AppData.DestFileTblPtr->File[FileIndex].Movename, "directory2/movename/", sizeof(DS_AppData.DestFileTblPtr->File[FileIndex].Movename));