From: Piotr Kosko
Date: Fri, 27 May 2016 10:05:50 +0000 (+0200)
Subject: [Contact] Added more restrictive validation of filter in findByUsageCount
X-Git-Tag: submit/tizen/20160530.025304~3
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F49%2F71849%2F1;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git
[Contact] Added more restrictive validation of filter in findByUsageCount
[Feature] Added more validation of filter in findByUsageCount - value and type are checked
for validyty - value shouldn't be less than 0, type should be one of values in enum.
[Verification] Code compiles without errors.
Contact TCT passrate r11 is 100%.
Change-Id: Iee3b6a86eb931f6fda3fc9304771837d5a4f5ad5
Signed-off-by: Piotr Kosko
---
diff --git a/src/contact/contact_manager.cc b/src/contact/contact_manager.cc
index 319811fb..aeab4f2d 100755
--- a/src/contact/contact_manager.cc
+++ b/src/contact/contact_manager.cc
@@ -925,6 +925,10 @@ PlatformResult ContactManagerFindByUsageCount(const JsonObject& args, JsonArray&
const auto& match = filter.get("matchValue");
if (match.is()){
match_value = static_cast(match.get());
+ if (match_value < 0) {
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR,
+ "Match value cannot be less than 0");
+ }
ret = contacts_filter_add_int(filter_handle,
_contacts_person_usage.times_used,
CONTACTS_MATCH_EQUAL,
@@ -989,6 +993,10 @@ PlatformResult ContactManagerFindByUsageCount(const JsonObject& args, JsonArray&
}
// adding usage type to filter
contacts_usage_type_e type = Person::UsageTypeFromString(attribute_name);
+ if (CONTACTS_USAGE_STAT_TYPE_NONE == type) {
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR,
+ "Type of usage in filter should be one of ContactUsageType values");
+ }
ret = contacts_filter_add_int(filter_handle,
_contacts_person_usage.usage_type,
CONTACTS_MATCH_EQUAL,