From: Markus Jung Date: Thu, 31 Mar 2016 07:39:54 +0000 (+0900) Subject: [IOT-1052] Resource container fixes X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c9b592354a7b2d48a9e3ef96c87521553d78bfd;p=contrib%2Fiotivity.git [IOT-1052] Resource container fixes Resource container fixes: - Using strncat instead of strcat and including a length check for configured paths. - Checks for non-null references in Configuration.cpp - Member initializiation in BundleInfoInternal.cpp Change-Id: Ifb4c50a76b22e7c2b06465187c90a8328eda5a90 Signed-off-by: Markus Jung Reviewed-on: https://gerrit.iotivity.org/gerrit/7509 Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka Reviewed-by: JungHo Kim --- diff --git a/service/resource-container/src/BundleInfoInternal.cpp b/service/resource-container/src/BundleInfoInternal.cpp index c6e7706..a15ae9c 100644 --- a/service/resource-container/src/BundleInfoInternal.cpp +++ b/service/resource-container/src/BundleInfoInternal.cpp @@ -32,6 +32,7 @@ namespace OIC m_resourceCreator = nullptr; m_resourceDestroyer = nullptr; m_bundleHandle = nullptr; + m_so_bundle = nullptr; m_loaded = false; m_activated = false; diff --git a/service/resource-container/src/Configuration.cpp b/service/resource-container/src/Configuration.cpp index 96f9526..c1dd082 100644 --- a/service/resource-container/src/Configuration.cpp +++ b/service/resource-container/src/Configuration.cpp @@ -95,9 +95,10 @@ namespace OIC { try { - if (m_xmlDoc.first_node()) + bundle = m_xmlDoc.first_node(); + if (bundle) { - for (bundle = m_xmlDoc.first_node()->first_node(BUNDLE_TAG); bundle; bundle = + for (bundle = bundle->first_node(BUNDLE_TAG); bundle; bundle = bundle->next_sibling()) { std::map< std::string, std::string > bundleMap; @@ -139,9 +140,10 @@ namespace OIC std::map< std::string, std::string > bundleConfigMap; // - if (m_xmlDoc.first_node()) + bundle = m_xmlDoc.first_node(); + if (bundle) { - for (bundle = m_xmlDoc.first_node()->first_node(BUNDLE_TAG); bundle; bundle = + for (bundle = bundle->first_node(BUNDLE_TAG); bundle; bundle = bundle->next_sibling()) { // @@ -207,9 +209,10 @@ namespace OIC try { // - if (m_xmlDoc.first_node()) + bundle = m_xmlDoc.first_node(); + if (bundle) { - for (bundle = m_xmlDoc.first_node()->first_node(BUNDLE_TAG); bundle; + for (bundle = bundle->first_node(BUNDLE_TAG); bundle; bundle = bundle->next_sibling()) { // @@ -222,9 +225,9 @@ namespace OIC { OIC_LOG_V(INFO, CONTAINER_TAG, "Inspecting"); // - if (bundle->first_node(OUTPUT_RESOURCES_TAG)){ - for (resource = bundle->first_node(OUTPUT_RESOURCES_TAG)-> - first_node(OUTPUT_RESOURCE_INFO); + bundle = bundle->first_node(OUTPUT_RESOURCES_TAG); + if (bundle){ + for (resource = bundle->first_node(OUTPUT_RESOURCE_INFO); resource; resource = resource->next_sibling()) { @@ -324,9 +327,10 @@ namespace OIC try { // - if (m_xmlDoc.first_node()) + bundle = m_xmlDoc.first_node(); + if (bundle) { - for (bundle = m_xmlDoc.first_node()->first_node(BUNDLE_TAG); bundle; bundle = + for (bundle = bundle->first_node(BUNDLE_TAG); bundle; bundle = bundle->next_sibling()) { // @@ -339,9 +343,10 @@ namespace OIC { OIC_LOG_V(INFO, CONTAINER_TAG, "Inspecting"); // - if (bundle->first_node(OUTPUT_RESOURCES_TAG)) + bundle = bundle->first_node(OUTPUT_RESOURCES_TAG); + if (bundle) { - for (resource = bundle->first_node(OUTPUT_RESOURCES_TAG)-> + for (resource = bundle-> first_node(OUTPUT_RESOURCE_INFO); resource; resource = resource->next_sibling()) { diff --git a/service/resource-container/src/ResourceContainerImpl.cpp b/service/resource-container/src/ResourceContainerImpl.cpp index b8dfd46..a25bc9a 100644 --- a/service/resource-container/src/ResourceContainerImpl.cpp +++ b/service/resource-container/src/ResourceContainerImpl.cpp @@ -1001,7 +1001,7 @@ namespace OIC options[0].optionString = optionString; char classpath[1000]; strcpy(classpath, "-Djava.class.path="); - strcat(classpath, bundleInfo->getPath().c_str()); + strncat(classpath, bundleInfo->getPath().c_str(), BUNDLE_PATH_MAXLEN); OIC_LOG(INFO, CONTAINER_TAG, std::string("Configured classpath: ").append(classpath).c_str()); @@ -1010,7 +1010,7 @@ namespace OIC char libraryPath[1000]; strcpy(libraryPath, "-Djava.library.path="); - strcat(libraryPath, bundleInfo->getLibraryPath().c_str()); + strncat(libraryPath, bundleInfo->getLibraryPath().c_str(), BUNDLE_PATH_MAXLEN); options[2].optionString = libraryPath; OIC_LOG(INFO, CONTAINER_TAG, diff --git a/service/resource-container/src/ResourceContainerImpl.h b/service/resource-container/src/ResourceContainerImpl.h index 1428514..b7cb614 100644 --- a/service/resource-container/src/ResourceContainerImpl.h +++ b/service/resource-container/src/ResourceContainerImpl.h @@ -42,6 +42,7 @@ #define BUNDLE_ACTIVATION_WAIT_SEC 10 #define BUNDLE_SET_GET_WAIT_SEC 10 +#define BUNDLE_PATH_MAXLEN 300 using namespace OIC::Service;