Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tizen] Account for 0-terminator in WriteConfigValueStr #26510

Merged
merged 3 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/platform/Tizen/PosixConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ CHIP_ERROR PosixConfig::ReadConfigValue(Key key, uint64_t & val)
CHIP_ERROR PosixConfig::ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen)
{
VerifyOrReturnError(buf != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
return PersistedStorage::KeyValueStoreMgr().Get(key.Name, buf, bufSize, &outLen);

auto err = PersistedStorage::KeyValueStoreMgr().Get(key.Name, buf, bufSize, &outLen);
VerifyOrReturnError(err == CHIP_NO_ERROR, err);

// We are storing string values in the config store without
// the null terminator, so we need to add it here.
VerifyOrReturnError(bufSize >= outLen + 1, CHIP_ERROR_BUFFER_TOO_SMALL);
buf[outLen] = '\0';

return CHIP_NO_ERROR;
}

CHIP_ERROR PosixConfig::ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen)
Expand Down
5 changes: 2 additions & 3 deletions src/platform/tests/TestConfigurationMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ static void TestConfigurationMgr_GetProductId(nlTestSuite * inSuite, void * inCo
* Test Suite. It lists all the test functions.
*/
static const nlTest sTests[] = {

NL_TEST_DEF("Test PlatformMgr::Init", TestPlatformMgr_Init),
#if !defined(NDEBUG)
NL_TEST_DEF("Test PlatformMgr::RunUnitTest", TestPlatformMgr_RunUnitTest),
Expand All @@ -466,8 +465,8 @@ static const nlTest sTests[] = {
NL_TEST_DEF("Test ConfigurationMgr::GetVendorId", TestConfigurationMgr_GetVendorId),
NL_TEST_DEF("Test ConfigurationMgr::GetProductName", TestConfigurationMgr_GetProductName),
NL_TEST_DEF("Test ConfigurationMgr::GetProductId", TestConfigurationMgr_GetProductId),
NL_TEST_SENTINEL()
}; // namespace
NL_TEST_SENTINEL(),
};

/**
* Set up the test suite.
Expand Down