From ac8331f9c1a698719239cf72204659dda052fa1a Mon Sep 17 00:00:00 2001 From: Robert Wojciechowski Date: Tue, 24 Sep 2024 14:51:34 +0200 Subject: [PATCH 1/3] Various bug fixes --- src/common/commonutils/CommandUtils.c | 4 +++- src/common/commonutils/DeviceInfoUtils.c | 13 ++++++++--- src/common/commonutils/FileUtils.c | 11 +++++---- src/common/commonutils/PassUtils.c | 13 ++++++++--- src/common/commonutils/SshUtils.c | 6 +++-- src/common/commonutils/UrlUtils.c | 2 +- .../tests/CommandRunnerTests.cpp | 12 ++++++++++ .../configuration/src/lib/Configuration.c | 3 ++- src/platform/MpiServer.c | 3 ++- src/platform/tests/PlatformTests.cpp | 23 ++++--------------- 10 files changed, 56 insertions(+), 34 deletions(-) diff --git a/src/common/commonutils/CommandUtils.c b/src/common/commonutils/CommandUtils.c index 90019c0ef..4bc74dda0 100644 --- a/src/common/commonutils/CommandUtils.c +++ b/src/common/commonutils/CommandUtils.c @@ -285,6 +285,7 @@ int ExecuteCommand(void* context, const char* command, bool replaceEol, bool for // Read the text result from the output of the command, if any, whether command succeeded or failed if (NULL != textResult) { + *textResult = NULL; resultsFile = fopen(commandTextResultFile, "r"); if (resultsFile) { @@ -339,7 +340,7 @@ int ExecuteCommand(void* context, const char* command, bool replaceEol, bool for OsConfigLogInfo(log, "Context: '%p'", context); OsConfigLogInfo(log, "Command: '%s'", command); OsConfigLogInfo(log, "Status: %d (errno: %d)", status, errno); - OsConfigLogInfo(log, "Text result: '%s'", (NULL != textResult) ? (*textResult) : ""); + OsConfigLogInfo(log, "Text result: '%s'", (NULL != textResult && NULL != *textResult) ? (*textResult) : ""); } return status; @@ -377,5 +378,6 @@ char* HashCommand(const char* source, void* log) OsConfigLogError(log, "HashCommand: out of memory"); } + FREE_MEMORY(command); return (0 == status) ? hash : NULL; } \ No newline at end of file diff --git a/src/common/commonutils/DeviceInfoUtils.c b/src/common/commonutils/DeviceInfoUtils.c index 712398462..613c09279 100644 --- a/src/common/commonutils/DeviceInfoUtils.c +++ b/src/common/commonutils/DeviceInfoUtils.c @@ -26,7 +26,7 @@ void RemovePrefixBlanks(char* target) i += 1; } - memcpy(target, target + i, targetLength - i); + memmove(target, target + i, targetLength - i); target[targetLength - i] = 0; } @@ -43,7 +43,7 @@ void RemovePrefixUpTo(char* target, char marker) if (equalSign) { targetLength = strlen(equalSign + 1); - memcpy(target, equalSign + 1, targetLength); + memmove(target, equalSign + 1, targetLength); target[targetLength] = 0; } } @@ -61,7 +61,7 @@ void RemovePrefixUpToString(char* target, const char* marker) if (equalSign) { targetLength = (int)strlen(equalSign); - memcpy(target, equalSign, targetLength); + memmove(target, equalSign, targetLength); target[targetLength] = 0; } } @@ -354,6 +354,7 @@ long GetTotalMemory(void* log) if (NULL != textResult) { totalMemory = atol(textResult); + FREE_MEMORY(textResult); } if (IsFullLoggingEnabled()) @@ -373,6 +374,7 @@ long GetFreeMemory(void* log) if (NULL != textResult) { freeMemory = atol(textResult); + FREE_MEMORY(textResult); } if (IsFullLoggingEnabled()) @@ -391,6 +393,7 @@ char* GetProductName(void* log) if ((NULL == textResult) || (0 == strlen(textResult))) { + FREE_MEMORY(textResult); textResult = GetHardwareProperty(osProductNameAlternateCommand, false, log); } @@ -410,6 +413,7 @@ char* GetProductVendor(void* log) if ((NULL == textResult) || (0 == strlen(textResult))) { + FREE_MEMORY(textResult); textResult = GetHardwareProperty(osProductVendorAlternateCommand, false, log); } @@ -429,6 +433,7 @@ char* GetProductVersion(void* log) if ((NULL == textResult) || (0 == strlen(textResult))) { + FREE_MEMORY(textResult); textResult = GetHardwareProperty(osProductVersionAlternateCommand, false, log); } @@ -697,6 +702,8 @@ int CheckLoginUmask(const char* desired, char** reason, void* log) OsConfigCaptureReason(reason, "Current login UMASK '%s' does not match desired '%s'", current, desired); status = ENOENT; } + + FREE_MEMORY(current); } return status; diff --git a/src/common/commonutils/FileUtils.c b/src/common/commonutils/FileUtils.c index cfe1601e7..143a7dbaa 100644 --- a/src/common/commonutils/FileUtils.c +++ b/src/common/commonutils/FileUtils.c @@ -309,6 +309,11 @@ bool ConcatenateFiles(const char* firstFileName, const char* secondFileName, boo int RestrictFileAccessToCurrentAccountOnly(const char* fileName) { + if (NULL == fileName) + { + return EINVAL; + } + // S_ISUID (4000): Set user ID on execution // S_ISGID (2000): Set group ID on execution // S_IRUSR (0400): Read permission, owner @@ -1547,14 +1552,13 @@ static int FindTextInCommandOutput(const char* command, const char* text, void* status = ENOENT; OsConfigLogInfo(log, "FindTextInCommandOutput: '%s' not found in '%s' output", text, command); } - - FREE_MEMORY(results); } else { OsConfigLogInfo(log, "FindTextInCommandOutput: command '%s' failed with %d", command, status); } + FREE_MEMORY(results); return status; } @@ -1630,10 +1634,9 @@ char* GetStringOptionFromBuffer(const char* buffer, const char* option, char sep { OsConfigLogError(log, "GetStringOptionFromBuffer: failed to duplicate result string (%d)", errno); } - - FREE_MEMORY(internal); } + FREE_MEMORY(internal); return result; } diff --git a/src/common/commonutils/PassUtils.c b/src/common/commonutils/PassUtils.c index a3fcfe0ed..bc0da882d 100644 --- a/src/common/commonutils/PassUtils.c +++ b/src/common/commonutils/PassUtils.c @@ -81,9 +81,14 @@ int CheckEnsurePasswordReuseIsLimited(int remember, char** reason, void* log) g_etcPamdCommonPassword, g_etcPamdSystemAuth, g_remember); } - if (status && (false == FindPamModule(g_pamUnixSo, log))) + if (status) { - OsConfigCaptureReason(reason, "The PAM module '%s' is not available. Automatic remediation is not possible", g_pamUnixSo); + char* pamModule = FindPamModule(g_pamUnixSo, log); + if(NULL == pamModule) + { + OsConfigCaptureReason(reason, "The PAM module '%s' is not available. Automatic remediation is not possible", g_pamUnixSo); + } + free(pamModule); } return status; @@ -219,7 +224,7 @@ int CheckLockoutForFailedPasswordAttempts(const char* fileName, const char* pamS continue; } else if ((NULL != strstr(line, auth)) && (NULL != strstr(line, pamSo)) && - (NULL != (authValue = GetStringOptionFromBuffer(line, auth, ' ', log))) && (0 == strcmp(authValue, required)) && FreeAndReturnTrue(authValue) && + (NULL != (authValue = GetStringOptionFromBuffer(line, auth, ' ', log))) && (0 == strcmp(authValue, required)) && (0 <= (deny = GetIntegerOptionFromBuffer(line, "deny", '=', log))) && (deny <= 5) && (0 < (unlockTime = GetIntegerOptionFromBuffer(line, "unlock_time", '=', log)))) { @@ -229,10 +234,12 @@ int CheckLockoutForFailedPasswordAttempts(const char* fileName, const char* pamS auth, required, pamSo, deny, unlockTime, fileName); status = 0; + FREE_MEMORY(authValue); break; } else { + FREE_MEMORY(authValue); status = ENOENT; } diff --git a/src/common/commonutils/SshUtils.c b/src/common/commonutils/SshUtils.c index f0efe1ea0..5438e9e22 100644 --- a/src/common/commonutils/SshUtils.c +++ b/src/common/commonutils/SshUtils.c @@ -275,7 +275,7 @@ static int IsSshConfigIncludeSupported(void* log) static int CheckOnlyApprovedMacAlgorithmsAreUsed(const char* macs, char** reason, void* log) { - char* sshMacs = DuplicateStringToLowercase(g_sshMacs); + char* sshMacs = NULL; char* macsValue = NULL; char* value = NULL; size_t macsValueLength = 0; @@ -292,6 +292,7 @@ static int CheckOnlyApprovedMacAlgorithmsAreUsed(const char* macs, char** reason return status; } + sshMacs = DuplicateStringToLowercase(g_sshMacs); if (NULL == (macsValue = GetSshServerState(sshMacs, log))) { OsConfigLogError(log, "CheckOnlyApprovedMacAlgorithmsAreUsed: '%s' not found in SSH Server response from 'sshd -T'", sshMacs); @@ -343,7 +344,7 @@ static int CheckOnlyApprovedMacAlgorithmsAreUsed(const char* macs, char** reason static int CheckAppropriateCiphersForSsh(const char* ciphers, char** reason, void* log) { - char* sshCiphers = DuplicateStringToLowercase(g_sshCiphers); + char* sshCiphers = NULL; char* ciphersValue = NULL; char* value = NULL; size_t ciphersValueLength = 0; @@ -360,6 +361,7 @@ static int CheckAppropriateCiphersForSsh(const char* ciphers, char** reason, voi return status; } + sshCiphers = DuplicateStringToLowercase(g_sshCiphers); if (NULL == (ciphersValue = GetSshServerState(sshCiphers, log))) { OsConfigLogError(log, "CheckAppropriateCiphersForSsh: '%s' not found in SSH Server response", sshCiphers); diff --git a/src/common/commonutils/UrlUtils.c b/src/common/commonutils/UrlUtils.c index e989be9cf..d451313b9 100644 --- a/src/common/commonutils/UrlUtils.c +++ b/src/common/commonutils/UrlUtils.c @@ -12,7 +12,7 @@ char* UrlEncode(char* target) int i = 0, j = 0; int targetLength = (int)strlen(target); - int encodedLength = 3 * targetLength; + int encodedLength = 3 * targetLength + 1; char* encodedTarget = (char*)malloc(encodedLength); if (NULL != encodedTarget) { diff --git a/src/modules/commandrunner/tests/CommandRunnerTests.cpp b/src/modules/commandrunner/tests/CommandRunnerTests.cpp index df02aa562..22d6ba1f2 100644 --- a/src/modules/commandrunner/tests/CommandRunnerTests.cpp +++ b/src/modules/commandrunner/tests/CommandRunnerTests.cpp @@ -127,6 +127,7 @@ namespace Tests EXPECT_EQ(MMI_OK, m_commandRunner->Get(m_component, m_reportedObject, &reportedPayload, &payloadSizeBytes)); EXPECT_TRUE(IsJsonEq(Command::Status::Serialize(status), std::string(reportedPayload, payloadSizeBytes))); + delete[] reportedPayload; } TEST_F(CommandRunnerTests, RunCommandTimeout) @@ -145,6 +146,7 @@ namespace Tests EXPECT_EQ(MMI_OK, m_commandRunner->Get(m_component, m_reportedObject, &reportedPayload, &payloadSizeBytes)); EXPECT_TRUE(IsJsonEq(Command::Status::Serialize(status), std::string(reportedPayload, payloadSizeBytes))); + delete[] reportedPayload; } TEST_F(CommandRunnerTests, RunCommandSingleLineTextResult) @@ -163,6 +165,7 @@ namespace Tests EXPECT_EQ(MMI_OK, m_commandRunner->Get(m_component, m_reportedObject, &reportedPayload, &payloadSizeBytes)); EXPECT_TRUE(IsJsonEq(Command::Status::Serialize(status), std::string(reportedPayload, payloadSizeBytes))); + delete[] reportedPayload; } TEST_F(CommandRunnerTests, RunCommandLimitedPayloadSize) @@ -190,6 +193,7 @@ namespace Tests EXPECT_EQ(MMI_OK, commandRunner.Get(m_component, m_reportedObject, &reportedPayload, &payloadSizeBytes)); EXPECT_TRUE(IsJsonEq(Command::Status::Serialize(status), std::string(reportedPayload, payloadSizeBytes))); + delete[] reportedPayload; } TEST_F(CommandRunnerTests, RunCommandMaximumCacheSize) @@ -222,6 +226,7 @@ namespace Tests EXPECT_EQ(MMI_OK, m_commandRunner->Set(m_component, m_desiredObject, (MMI_JSON_STRING)(refresh.c_str()), refresh.size())); EXPECT_EQ(MMI_OK, m_commandRunner->Get(m_component, m_reportedObject, &reportedPayload, &payloadSizeBytes)); EXPECT_TRUE(IsJsonEq(Command::Status::Serialize(expectedResult.second), std::string(reportedPayload, payloadSizeBytes))); + delete[] reportedPayload; } // Add one more command to the cache @@ -237,6 +242,7 @@ namespace Tests // Get the last command from the cache EXPECT_EQ(MMI_OK, m_commandRunner->Get(m_component, m_reportedObject, &reportedPayload, &payloadSizeBytes)); EXPECT_TRUE(IsJsonEq(Command::Status::Serialize(lastStatus), std::string(reportedPayload, payloadSizeBytes))); + delete[] reportedPayload; // The first command should have been removed from the cache Command::Arguments refreshFirstCommand(expectedResults[0].first, "", Command::Action::RefreshCommandStatus, 0, false); @@ -246,6 +252,7 @@ namespace Tests // The last command should still be reported (set as command to report) and in the cache EXPECT_EQ(MMI_OK, m_commandRunner->Get(m_component, m_reportedObject, &reportedPayload, &payloadSizeBytes)); EXPECT_TRUE(IsJsonEq(Command::Status::Serialize(lastStatus), std::string(reportedPayload, payloadSizeBytes))); + delete[] reportedPayload; } TEST_F(CommandRunnerTests, RefreshCommand) @@ -273,6 +280,7 @@ namespace Tests // The last run command should be reported EXPECT_EQ(MMI_OK, m_commandRunner->Get(m_component, m_reportedObject, &reportedPayload, &payloadSizeBytes)); EXPECT_TRUE(IsJsonEq(Command::Status::Serialize(status2), std::string(reportedPayload, payloadSizeBytes))); + delete[] reportedPayload; // Refresh the command Command::Arguments refresh(id1, "", Command::Action::RefreshCommandStatus, 0, false); @@ -284,6 +292,7 @@ namespace Tests // The refreshed command should be reported EXPECT_EQ(MMI_OK, m_commandRunner->Get(m_component, m_reportedObject, &reportedPayload, &payloadSizeBytes)); EXPECT_TRUE(IsJsonEq(Command::Status::Serialize(status1), std::string(reportedPayload, payloadSizeBytes))); + delete[] reportedPayload; } TEST_F(CommandRunnerTests, CancelCommandInProgress) @@ -306,6 +315,7 @@ namespace Tests EXPECT_EQ(MMI_OK, m_commandRunner->Get(m_component, m_reportedObject, &reportedPayload, &payloadSizeBytes)); EXPECT_TRUE(IsJsonEq(Command::Status::Serialize(status), std::string(reportedPayload, payloadSizeBytes))); + delete[] reportedPayload; } TEST_F(CommandRunnerTests, RepeatCommandId) @@ -327,6 +337,7 @@ namespace Tests EXPECT_EQ(MMI_OK, m_commandRunner->Get(m_component, m_reportedObject, &reportedPayload, &payloadSizeBytes)); EXPECT_TRUE(IsJsonEq(Command::Status::Serialize(status), std::string(reportedPayload, payloadSizeBytes))); + delete[] reportedPayload; } TEST_F(CommandRunnerTests, RepeatCommand) @@ -346,6 +357,7 @@ namespace Tests EXPECT_EQ(MMI_OK, m_commandRunner->Get(m_component, m_reportedObject, &reportedPayload, &payloadSizeBytes)); EXPECT_TRUE(IsJsonEq(Command::Status::Serialize(status), std::string(reportedPayload, payloadSizeBytes))); + delete[] reportedPayload; } TEST_F(CommandRunnerTests, ExecuteCommand) diff --git a/src/modules/configuration/src/lib/Configuration.c b/src/modules/configuration/src/lib/Configuration.c index 424a34cbc..2f622dec2 100644 --- a/src/modules/configuration/src/lib/Configuration.c +++ b/src/modules/configuration/src/lib/Configuration.c @@ -90,6 +90,7 @@ static char* LoadConfigurationFromFile(const char* fileName) g_iotHubManagementEnabled = IsIotHubManagementEnabledInJsonConfig(jsonConfiguration); g_iotHubProtocol = GetIotHubProtocolFromJsonConfig(jsonConfiguration, ConfigurationGetLog()); g_gitManagementEnabled = GetGitManagementFromJsonConfig(jsonConfiguration, ConfigurationGetLog()); + FREE_MEMORY(g_gitBranch); g_gitBranch = GetGitBranchFromJsonConfig(jsonConfiguration, ConfigurationGetLog()); } else @@ -597,7 +598,7 @@ int ConfigurationMmiSet(MMI_HANDLE clientSession, const char* componentName, con } else if (0 == strcmp(objectName, g_desiredGitBranchObject)) { - if (NULL != (jsonString = (char*)json_value_get_string(jsonValue))) + if (NULL != (jsonString = json_value_get_string(jsonValue))) { if (jsonString) { diff --git a/src/platform/MpiServer.c b/src/platform/MpiServer.c index 45ad51c36..8adf0d772 100644 --- a/src/platform/MpiServer.c +++ b/src/platform/MpiServer.c @@ -199,7 +199,7 @@ HTTP_STATUS HandleMpiCall(const char* uri, const char* requestBody, char** respo const char* client = NULL; const char* component = NULL; const char* object = NULL; - const char* payload = NULL; + char* payload = NULL; int maxPayloadSizeBytes = 0; int estimatedSize = 0; const char* responseFormat = "\"%s\""; @@ -424,6 +424,7 @@ HTTP_STATUS HandleMpiCall(const char* uri, const char* requestBody, char** respo } } + json_free_serialized_string(payload); json_value_free(rootValue); return status; diff --git a/src/platform/tests/PlatformTests.cpp b/src/platform/tests/PlatformTests.cpp index 0d9e2ad37..1887e3b0e 100644 --- a/src/platform/tests/PlatformTests.cpp +++ b/src/platform/tests/PlatformTests.cpp @@ -26,12 +26,7 @@ namespace Tests } else { - char* handle = new (std::nothrow) char[strlen(g_mockHandle) + 1]; - if (handle != nullptr) - { - strcpy(handle, g_mockHandle); - } - return (MPI_HANDLE)handle; + return (MPI_HANDLE)strdup(g_mockHandle); } } @@ -59,12 +54,8 @@ namespace Tests } else { - *payload = new (std::nothrow) char[strlen(g_mockPayload) + 1]; - if (*payload != nullptr) - { - strcpy(*payload, g_mockPayload); - *payloadSize = strlen(g_mockPayload); - } + *payload = strdup(g_mockPayload); + *payloadSize = strlen(g_mockPayload); return MPI_OK; } } @@ -81,12 +72,8 @@ namespace Tests { UNUSED(handle); - *payload = new (std::nothrow) char[strlen(g_mockPayload) + 1]; - if (*payload != nullptr) - { - strcpy(*payload, g_mockPayload); - *payloadSize = strlen(g_mockPayload); - } + *payload = strdup(g_mockPayload); + *payloadSize = strlen(g_mockPayload); return MPI_OK; } From 7b9ed2053926a6252851061a7a842c79a5828eee Mon Sep 17 00:00:00 2001 From: Robert Wojciechowski Date: Mon, 14 Oct 2024 09:05:37 +0200 Subject: [PATCH 2/3] Fix code review issues #1 --- src/common/commonutils/PassUtils.c | 6 +++--- src/common/commonutils/SshUtils.c | 11 +++++++++-- src/common/commonutils/UrlUtils.c | 2 +- src/modules/configuration/src/lib/Configuration.c | 1 + 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/common/commonutils/PassUtils.c b/src/common/commonutils/PassUtils.c index bc0da882d..7704e5a6f 100644 --- a/src/common/commonutils/PassUtils.c +++ b/src/common/commonutils/PassUtils.c @@ -62,6 +62,7 @@ static char* FindPamModule(const char* pamModule, void* log) int CheckEnsurePasswordReuseIsLimited(int remember, char** reason, void* log) { int status = ENOENT; + char* pamModule = NULL; if (0 == CheckFileExists(g_etcPamdCommonPassword, NULL, log)) { @@ -83,12 +84,11 @@ int CheckEnsurePasswordReuseIsLimited(int remember, char** reason, void* log) if (status) { - char* pamModule = FindPamModule(g_pamUnixSo, log); - if(NULL == pamModule) + if (NULL == (pamModule = FindPamModule(g_pamUnixSo, log))) { OsConfigCaptureReason(reason, "The PAM module '%s' is not available. Automatic remediation is not possible", g_pamUnixSo); } - free(pamModule); + FREE_MEMORY(pamModule); } return status; diff --git a/src/common/commonutils/SshUtils.c b/src/common/commonutils/SshUtils.c index 5438e9e22..42e59016b 100644 --- a/src/common/commonutils/SshUtils.c +++ b/src/common/commonutils/SshUtils.c @@ -291,8 +291,12 @@ static int CheckOnlyApprovedMacAlgorithmsAreUsed(const char* macs, char** reason { return status; } + else if (NULL == (sshMacs = DuplicateStringToLowercase(g_sshMacs))) + { + OsConfigLogError(log, "CheckOnlyApprovedMacAlgorithmsAreUsed: failed to duplicate string to lowercase"); + return ENOMEM; + } - sshMacs = DuplicateStringToLowercase(g_sshMacs); if (NULL == (macsValue = GetSshServerState(sshMacs, log))) { OsConfigLogError(log, "CheckOnlyApprovedMacAlgorithmsAreUsed: '%s' not found in SSH Server response from 'sshd -T'", sshMacs); @@ -359,9 +363,12 @@ static int CheckAppropriateCiphersForSsh(const char* ciphers, char** reason, voi else if (0 != IsSshServerActive(log)) { return status; + } else if(NULL == (sshCiphers = DuplicateStringToLowercase(g_sshCiphers))) + { + OsConfigLogError(log, "CheckAppropriateCiphersForSsh: failed to duplicate string to lowercase"); + return ENOMEM; } - sshCiphers = DuplicateStringToLowercase(g_sshCiphers); if (NULL == (ciphersValue = GetSshServerState(sshCiphers, log))) { OsConfigLogError(log, "CheckAppropriateCiphersForSsh: '%s' not found in SSH Server response", sshCiphers); diff --git a/src/common/commonutils/UrlUtils.c b/src/common/commonutils/UrlUtils.c index d451313b9..36c7c8399 100644 --- a/src/common/commonutils/UrlUtils.c +++ b/src/common/commonutils/UrlUtils.c @@ -12,7 +12,7 @@ char* UrlEncode(char* target) int i = 0, j = 0; int targetLength = (int)strlen(target); - int encodedLength = 3 * targetLength + 1; + int encodedLength = (3 * targetLength) + 1; char* encodedTarget = (char*)malloc(encodedLength); if (NULL != encodedTarget) { diff --git a/src/modules/configuration/src/lib/Configuration.c b/src/modules/configuration/src/lib/Configuration.c index 2f622dec2..6932e83fb 100644 --- a/src/modules/configuration/src/lib/Configuration.c +++ b/src/modules/configuration/src/lib/Configuration.c @@ -90,6 +90,7 @@ static char* LoadConfigurationFromFile(const char* fileName) g_iotHubManagementEnabled = IsIotHubManagementEnabledInJsonConfig(jsonConfiguration); g_iotHubProtocol = GetIotHubProtocolFromJsonConfig(jsonConfiguration, ConfigurationGetLog()); g_gitManagementEnabled = GetGitManagementFromJsonConfig(jsonConfiguration, ConfigurationGetLog()); + FREE_MEMORY(g_gitBranch); g_gitBranch = GetGitBranchFromJsonConfig(jsonConfiguration, ConfigurationGetLog()); } From 456f01660b962af3340eb1fd110548ed5717c7db Mon Sep 17 00:00:00 2001 From: Robert Wojciechowski Date: Tue, 15 Oct 2024 09:46:27 +0200 Subject: [PATCH 3/3] Fix code review issues #2 --- src/common/commonutils/SshUtils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/commonutils/SshUtils.c b/src/common/commonutils/SshUtils.c index 42e59016b..1e8e8a58d 100644 --- a/src/common/commonutils/SshUtils.c +++ b/src/common/commonutils/SshUtils.c @@ -363,7 +363,8 @@ static int CheckAppropriateCiphersForSsh(const char* ciphers, char** reason, voi else if (0 != IsSshServerActive(log)) { return status; - } else if(NULL == (sshCiphers = DuplicateStringToLowercase(g_sshCiphers))) + } + else if (NULL == (sshCiphers = DuplicateStringToLowercase(g_sshCiphers))) { OsConfigLogError(log, "CheckAppropriateCiphersForSsh: failed to duplicate string to lowercase"); return ENOMEM;