diff --git a/src/platform/Tizen/PosixConfig.cpp b/src/platform/Tizen/PosixConfig.cpp index fc65c24bf189a9..c8b2d36d8271bf 100644 --- a/src/platform/Tizen/PosixConfig.cpp +++ b/src/platform/Tizen/PosixConfig.cpp @@ -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) diff --git a/src/platform/tests/TestConfigurationMgr.cpp b/src/platform/tests/TestConfigurationMgr.cpp index dafe5b209725a2..a113594868ad2c 100644 --- a/src/platform/tests/TestConfigurationMgr.cpp +++ b/src/platform/tests/TestConfigurationMgr.cpp @@ -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), @@ -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.