mirror of
https://github.com/espressif/openthread.git
synced 2026-08-24 19:29:52 +00:00
[posix] update the max size of file path to PATH_MAX (#10622)
The length of the configuration file path may exceed the default defined max length 255. This commit changes the name from `kFileNameMaxSize` to `kFilePathMaxSize` and sets its value to the PATH_MAX.
This commit is contained in:
@@ -47,7 +47,7 @@ ConfigFile::ConfigFile(const char *aFilePath)
|
||||
: mFilePath(aFilePath)
|
||||
{
|
||||
assert(mFilePath != nullptr);
|
||||
VerifyOrDie(strlen(mFilePath) + strlen(kSwapSuffix) < kFileNameMaxSize, OT_EXIT_FAILURE);
|
||||
VerifyOrDie(strlen(mFilePath) + strlen(kSwapSuffix) < kFilePathMaxSize, OT_EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bool ConfigFile::HasKey(const char *aKey) const
|
||||
@@ -163,7 +163,7 @@ exit:
|
||||
otError ConfigFile::Clear(const char *aKey)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
char swapFile[kFileNameMaxSize];
|
||||
char swapFile[kFilePathMaxSize];
|
||||
char line[kLineMaxSize];
|
||||
FILE *fp = nullptr;
|
||||
FILE *fpSwap = nullptr;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#define OT_POSIX_PLATFORM_CONFIG_FILE_HPP_
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <openthread/error.h>
|
||||
|
||||
@@ -115,7 +116,7 @@ private:
|
||||
const char *kCommentDelimiter = "#";
|
||||
const char *kSwapSuffix = ".swap";
|
||||
static constexpr uint16_t kLineMaxSize = 512;
|
||||
static constexpr uint16_t kFileNameMaxSize = 255;
|
||||
static constexpr uint16_t kFilePathMaxSize = PATH_MAX;
|
||||
|
||||
void Strip(char *aString) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user