Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2017-05-04 23:39:43 +0300
committerDavid Crocker <dcrocker@eschertech.com>2017-05-04 23:39:43 +0300
commit384d1d3ad400d70d8d2b191c435c439959b932c1 (patch)
treeb39870944ec67e584179bce0cab9db4d6f961aed /src/Storage
parent9d4c15c5dbd9566c51e765be0fe008275aff5915 (diff)
Release 1.19alpha
First working release of new WiFi code Axes moving other than X (possibly mapped), Y and Z are not taken to be part of the feed rate Introduced SafeStrncpy and SafeStrncat
Diffstat (limited to 'src/Storage')
-rw-r--r--src/Storage/MassStorage.cpp19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/Storage/MassStorage.cpp b/src/Storage/MassStorage.cpp
index 2084b359..4ba365fd 100644
--- a/src/Storage/MassStorage.cpp
+++ b/src/Storage/MassStorage.cpp
@@ -123,21 +123,12 @@ bool MassStorage::FindFirst(const char *directory, FileInfo &file_info)
TCHAR loc[FILENAME_LENGTH + 1];
// Remove the trailing '/' from the directory name
- size_t len = strnlen(directory, ARRAY_UPB(loc));
- if (len == 0)
+ SafeStrncpy(loc, directory, ARRAY_SIZE(loc));
+ const size_t len = strlen(loc);
+ if (len != 0 && loc[len - 1] == '/')
{
- loc[0] = 0;
- }
- else if (directory[len - 1] == '/')
- {
- strncpy(loc, directory, len - 1);
loc[len - 1] = 0;
}
- else
- {
- strncpy(loc, directory, len);
- loc[len] = 0;
- }
findDir.lfn = nullptr;
FRESULT res = f_opendir(&findDir, loc);
@@ -157,7 +148,7 @@ bool MassStorage::FindFirst(const char *directory, FileInfo &file_info)
if (file_info.fileName[0] == 0)
{
- strncpy(file_info.fileName, entry.fname, ARRAY_SIZE(file_info.fileName));
+ SafeStrncpy(file_info.fileName, entry.fname, ARRAY_SIZE(file_info.fileName));
}
file_info.size = entry.fsize;
@@ -189,7 +180,7 @@ bool MassStorage::FindNext(FileInfo &file_info)
if (file_info.fileName[0] == 0)
{
- strncpy(file_info.fileName, entry.fname, ARRAY_SIZE(file_info.fileName));
+ SafeStrncpy(file_info.fileName, entry.fname, ARRAY_SIZE(file_info.fileName));
}
file_info.lastModified = ConvertTimeStamp(entry.fdate, entry.ftime);