Skip to content

Commit a3f1204

Browse files
committed
Fix strncpy with sizeof(pointer) in findLastLog
This is the bug that was causing the sporadic 'SFE' file.
1 parent 54c3eaa commit a3f1204

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Firmware/RTK_Surveyor/menuMessages.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ void beginLogging(const char *customFileName)
435435
{
436436
reuseLastLog = false;
437437

438-
if (findLastLog(logFileName) == false)
438+
if (findLastLog(logFileName, sizeof(logFileName)) == false)
439439
log_d("Failed to find last log. Making new one.");
440440
else
441441
log_d("Using last log file.");
@@ -625,7 +625,7 @@ void endLogging(bool gotSemaphore, bool releaseSemaphore)
625625

626626
//Finds last log
627627
//Returns true if succesful
628-
bool findLastLog(char *lastLogName)
628+
bool findLastLog(char *lastLogNamePrt, int lastLogNameSize)
629629
{
630630
bool foundAFile = false;
631631

@@ -659,7 +659,7 @@ bool findLastLog(char *lastLogName)
659659
{
660660
if (strstr(fname, LOG_PREFIX) != nullptr)
661661
{
662-
strncpy(lastLogName, fname, sizeof(lastLogName) - 1); //Store this file as last known log file
662+
strncpy(lastLogNamePrt, fname, lastLogNameSize - 1); //Store this file as last known log file
663663
foundAFile = true;
664664
}
665665
}
@@ -692,7 +692,7 @@ bool findLastLog(char *lastLogName)
692692
{
693693
if (strstr(fname, LOG_PREFIX) != nullptr)
694694
{
695-
strncpy(lastLogName, fname, sizeof(lastLogName) - 1); //Store this file as last known log file
695+
strncpy(lastLogNamePrt, fname, lastLogNameSize - 1); //Store this file as last known log file
696696
foundAFile = true;
697697
}
698698
}

0 commit comments

Comments
 (0)