Fix metadata filter when using cached app info 58/273458/2
authorIlho Kim <ilho159.kim@samsung.com>
Wed, 6 Apr 2022 04:49:57 +0000 (13:49 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Wed, 6 Apr 2022 05:50:09 +0000 (14:50 +0900)
when compare metadata value using metadat filter
there is need to check the exact matching of values using 'strcmp' not 'strstr'

Change-Id: I61f85c4a3e50278077730eb7190caeb0f6b484eb
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/server/database/db_handle_provider.cc

index d5b9a44..013c8e9 100644 (file)
@@ -432,9 +432,12 @@ std::vector<std::shared_ptr<application_x>> DBHandleProvider::GetApplications(
         auto* node = reinterpret_cast<metadata_x*>(it->data);
         if (node->key != nullptr) {
           auto metadata = metadata_map.find(node->key);
-          if (metadata != metadata_map.end() &&
-              strstr(node->value ? node->value : "",
-                  metadata->second.c_str()) != nullptr) {
+          if (metadata == metadata_map.end())
+            continue;
+
+          if (metadata->second.empty() ||
+              strcmp(node->value ? node->value : "",
+                  metadata->second.c_str()) == 0) {
             pass = true;
             break;
           }