[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:
Zhanglong Xia
2024-08-19 11:24:59 -07:00
committed by GitHub
parent 4e053fe517
commit fb7b457ab2
2 changed files with 4 additions and 3 deletions
+2 -2
View File
@@ -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;
+2 -1
View File
@@ -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;