You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2023/01/09 15:38:50 UTC
[celix] 01/01: Fix several null pointer dereferences and uninitialized variables issues
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch feature/fix_issues_found_last_coverity_scan
in repository https://gitbox.apache.org/repos/asf/celix.git
commit c5251212e7025cf24736dee9676900f01f429d76
Author: Pepijn Noltes <pn...@apache.org>
AuthorDate: Mon Jan 9 16:38:11 2023 +0100
Fix several null pointer dereferences and uninitialized variables issues
These issue were found in the latest coverity scan.
---
bundles/deployment_admin/src/deployment_admin.c | 5 +++--
.../pubsub_protocol_lib/src/pubsub_wire_protocol_common.c | 2 +-
.../pubsub_protocol/pubsub_protocol_wire_v1/gtest/src/PS_WP_tests.cc | 3 +++
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/bundles/deployment_admin/src/deployment_admin.c b/bundles/deployment_admin/src/deployment_admin.c
index 6d513d31..9b1d5ccf 100644
--- a/bundles/deployment_admin/src/deployment_admin.c
+++ b/bundles/deployment_admin/src/deployment_admin.c
@@ -177,9 +177,8 @@ static celix_status_t deploymentAdmin_performRequest(deployment_admin_pt admin,
curl = curl_easy_init();
if (!curl) {
- status = CELIX_BUNDLE_EXCEPTION;
-
fw_log(celix_frameworkLogger_globalLogger(), CELIX_LOG_LEVEL_ERROR, "Error initializing curl.");
+ return CELIX_BUNDLE_EXCEPTION;
}
char* url;
@@ -199,6 +198,8 @@ static celix_status_t deploymentAdmin_performRequest(deployment_admin_pt admin,
} else {
fw_log(celix_frameworkLogger_globalLogger(), CELIX_LOG_LEVEL_ERROR, "Error creating send url for audit log url: %s", admin->auditlogUrl);
}
+ curl_easy_cleanup(curl);
+
return status;
}
diff --git a/bundles/pubsub/pubsub_protocol/pubsub_protocol_lib/src/pubsub_wire_protocol_common.c b/bundles/pubsub/pubsub_protocol/pubsub_protocol_lib/src/pubsub_wire_protocol_common.c
index eb867ab5..b6e883e1 100644
--- a/bundles/pubsub/pubsub_protocol/pubsub_protocol_lib/src/pubsub_wire_protocol_common.c
+++ b/bundles/pubsub/pubsub_protocol/pubsub_protocol_lib/src/pubsub_wire_protocol_common.c
@@ -108,7 +108,7 @@ celix_status_t pubsubProtocol_encodeMetadata(pubsub_protocol_message_t* message,
}
celix_status_t status = CELIX_SUCCESS;
CELIX_PROPERTIES_FOR_EACH(message->metadata.metadata, key) {
- const char *val = celix_properties_get(message->metadata.metadata, key, NULL);
+ const char *val = celix_properties_get(message->metadata.metadata, key, "");
if (status == CELIX_SUCCESS) {
status = pubsubProtocol_addNetstringEntryToBuffer(*bufferInOut, *bufferLengthInOut, &offset, key);
}
diff --git a/bundles/pubsub/pubsub_protocol/pubsub_protocol_wire_v1/gtest/src/PS_WP_tests.cc b/bundles/pubsub/pubsub_protocol/pubsub_protocol_wire_v1/gtest/src/PS_WP_tests.cc
index 1e5f03ea..02cf89d0 100644
--- a/bundles/pubsub/pubsub_protocol/pubsub_protocol_wire_v1/gtest/src/PS_WP_tests.cc
+++ b/bundles/pubsub/pubsub_protocol/pubsub_protocol_wire_v1/gtest/src/PS_WP_tests.cc
@@ -234,6 +234,7 @@ TEST_F(WireProtocolV1Test, WireProtocolV1Test_DecodeMetadata_Test) { // NOLINT(c
memcpy(exp + 4, "1:a,1:b,", 8);
pubsub_protocol_message_t message;
+ message.header.convertEndianess = false;
celix_status_t status = pubsubProtocol_v1_decodeMetadata(nullptr, exp, 12, &message);
ASSERT_EQ(status, CELIX_SUCCESS);
@@ -256,6 +257,7 @@ TEST_F(WireProtocolV1Test, WireProtocolV1Test_DecodeMetadata_EmptyKey_Test) { //
memcpy(exp + 4, "0:,1:b,", 7);
pubsub_protocol_message_t message;
+ message.header.convertEndianess = false;
celix_status_t status = pubsubProtocol_v1_decodeMetadata(nullptr, exp, 11, &message);
ASSERT_EQ(status, CELIX_SUCCESS);
@@ -277,6 +279,7 @@ TEST_F(WireProtocolV1Test, WireProtocolV1Test_DecodeMetadata_SpecialChars_Test)
memcpy(exp + 4, "4:a,:l,1:b,", 11);
pubsub_protocol_message_t message;
+ message.header.convertEndianess = false;
celix_status_t status = pubsubProtocol_v1_decodeMetadata(nullptr, &exp, 15, &message);
ASSERT_EQ(status, CELIX_SUCCESS);