Check length of input param for preventing from empty 82/112282/3 accepted/tizen/common/20170210.170342 accepted/tizen/ivi/20170210.083237 accepted/tizen/mobile/20170210.083203 accepted/tizen/wearable/20170210.083221 submit/tizen/20170210.054359
authorJooseok Song <seogii.song@samsung.com>
Tue, 31 Jan 2017 03:51:43 +0000 (12:51 +0900)
committerJooseok Song <seogii.song@samsung.com>
Tue, 31 Jan 2017 04:24:10 +0000 (13:24 +0900)
Change-Id: I1b87a56985e330c637cad25f56ec03fd840ac475

src/account.c

index 3874d04..59983d0 100644 (file)
@@ -628,8 +628,8 @@ ACCOUNT_API int account_set_user_name(account_h account, const char *user_name)
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
-       if (!user_name) {
-               ACCOUNT_SLOGE("(%s)-(%d) user_name is NULL.\n", __FUNCTION__, __LINE__);
+       if (!user_name || strlen(user_name) <= 0) {
+               ACCOUNT_SLOGE("(%s)-(%d) user_name is NULL or Empty.\n", __FUNCTION__, __LINE__);
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
@@ -652,8 +652,8 @@ ACCOUNT_API int account_set_display_name(account_h account, const char *display_
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
-       if (!display_name) {
-               ACCOUNT_SLOGE("(%s)-(%d) display_name is NULL.\n", __FUNCTION__, __LINE__);
+       if (!display_name || strlen(display_name) <= 0) {
+               ACCOUNT_SLOGE("(%s)-(%d) display_name is NULL or Empty.\n", __FUNCTION__, __LINE__);
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
@@ -676,8 +676,8 @@ ACCOUNT_API int account_set_email_address(account_h account, const char *email_a
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
-       if (!email_address) {
-               ACCOUNT_SLOGE("(%s)-(%d) email_address is NULL.\n", __FUNCTION__, __LINE__);
+       if (!email_address || strlen(email_address) <= 0) {
+               ACCOUNT_SLOGE("(%s)-(%d) email_address is NULL or Empty.\n", __FUNCTION__, __LINE__);
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
@@ -700,8 +700,8 @@ ACCOUNT_API int account_set_icon_path(account_h account, const char *icon_path)
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
-       if (!icon_path) {
-               ACCOUNT_SLOGE("(%s)-(%d) icon_path is NULL.\n", __FUNCTION__, __LINE__);
+       if (!icon_path || strlen(icon_path) <= 0) {
+               ACCOUNT_SLOGE("(%s)-(%d) icon_path is NULL or Empty.\n", __FUNCTION__, __LINE__);
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
@@ -724,8 +724,8 @@ ACCOUNT_API int account_set_source(account_h account, const char *source)
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
-       if (!source) {
-               ACCOUNT_SLOGE("(%s)-(%d) source is NULL.\n", __FUNCTION__, __LINE__);
+       if (!source || strlen(source) <= 0) {
+               ACCOUNT_SLOGE("(%s)-(%d) source is NULL or Empty.\n", __FUNCTION__, __LINE__);
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
        account_s *data = (account_s *)account;
@@ -747,8 +747,8 @@ ACCOUNT_API int account_set_package_name(account_h account, const char *package_
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
-       if (!package_name) {
-               ACCOUNT_SLOGE("(%s)-(%d) package_name is NULL.\n", __FUNCTION__, __LINE__);
+       if (!package_name || strlen(package_name) <= 0) {
+               ACCOUNT_SLOGE("(%s)-(%d) package_name is NULL or Empty.\n", __FUNCTION__, __LINE__);
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
@@ -771,8 +771,8 @@ ACCOUNT_API int account_set_domain_name(account_h account, const char *domain_na
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
-       if (!domain_name) {
-               ACCOUNT_SLOGE("(%s)-(%d) domain_name is NULL.\n", __FUNCTION__, __LINE__);
+       if (!domain_name || strlen(domain_name) <= 0) {
+               ACCOUNT_SLOGE("(%s)-(%d) domain_name is NULL or Empty.\n", __FUNCTION__, __LINE__);
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
        account_s *data = (account_s *)account;
@@ -794,8 +794,8 @@ ACCOUNT_API int account_set_access_token(account_h account, const char *access_t
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
-       if (!access_token) {
-               ACCOUNT_SLOGE("(%s)-(%d) access_token is NULL.\n", __FUNCTION__, __LINE__);
+       if (!access_token || strlen(access_token) <= 0) {
+               ACCOUNT_SLOGE("(%s)-(%d) access_token is NULL or Empty.\n", __FUNCTION__, __LINE__);
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
@@ -818,8 +818,8 @@ ACCOUNT_API int account_set_user_text(account_h account, int idx, const char *us
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
-       if (!user_txt) {
-               ACCOUNT_SLOGE("(%s)-(%d) user_txt is NULL.\n", __FUNCTION__, __LINE__);
+       if (!user_txt || strlen(user_txt) <= 0) {
+               ACCOUNT_SLOGE("(%s)-(%d) user_txt is NULL or Empty.\n", __FUNCTION__, __LINE__);
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
        if (idx >= USER_TXT_CNT || idx < 0) {
@@ -846,12 +846,12 @@ ACCOUNT_API int account_set_custom(account_h account, const char *key, const cha
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
-       if (!key) {
+       if (!key || strlen(key) <= 0) {
                ACCOUNT_SLOGE("(%s)-(%d) key is NULL.\n", __FUNCTION__, __LINE__);
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
-       if (!value) {
+       if (!value || strlen(value) <= 0) {
                ACCOUNT_SLOGE("(%s)-(%d) value is NULL.\n", __FUNCTION__, __LINE__);
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
@@ -988,6 +988,7 @@ ACCOUNT_API int account_set_capability(account_h account, const char *capability
 {
        ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("account handle is null"));
        ACCOUNT_RETURN_VAL((capability_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("capability_type is null"));
+       ACCOUNT_RETURN_VAL((strlen(capability_type) > 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("capability_type is Empty"));
 
        if ((capability_value != ACCOUNT_CAPABILITY_DISABLED) && (capability_value != ACCOUNT_CAPABILITY_ENABLED))
                return ACCOUNT_ERROR_INVALID_PARAMETER;
@@ -1885,8 +1886,8 @@ ACCOUNT_INTERNAL_API int account_type_set_app_id(account_type_h account_type, co
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
-       if (!app_id) {
-               ACCOUNT_SLOGE("(%s)-(%d) app_id is NULL.\n", __FUNCTION__, __LINE__);
+       if (!app_id || strlen(app_id) <= 0) {
+               ACCOUNT_SLOGE("(%s)-(%d) app_id is NULL or Empty.\n", __FUNCTION__, __LINE__);
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
@@ -1907,7 +1908,7 @@ ACCOUNT_INTERNAL_API int account_type_set_service_provider_id(account_type_h acc
        if (!account_type)
                return ACCOUNT_ERROR_INVALID_PARAMETER;
 
-       if (!service_provider_id)
+       if (!service_provider_id || strlen(service_provider_id) <= 0)
                return ACCOUNT_ERROR_INVALID_PARAMETER;
 
        account_type_s *data = (account_type_s *)account_type;
@@ -1927,7 +1928,7 @@ ACCOUNT_INTERNAL_API int account_type_set_icon_path(account_type_h account_type,
        if (!account_type)
                return ACCOUNT_ERROR_INVALID_PARAMETER;
 
-       if (!icon_path)
+       if (!icon_path || strlen(icon_path) <= 0)
                return ACCOUNT_ERROR_INVALID_PARAMETER;
 
        account_type_s *data = (account_type_s *)account_type;
@@ -1947,7 +1948,7 @@ ACCOUNT_INTERNAL_API int account_type_set_small_icon_path(account_type_h account
        if (!account_type)
                return ACCOUNT_ERROR_INVALID_PARAMETER;
 
-       if (!small_icon_path)
+       if (!small_icon_path || strlen(small_icon_path) <= 0)
                return ACCOUNT_ERROR_INVALID_PARAMETER;
 
        account_type_s *data = (account_type_s *)account_type;
@@ -1980,7 +1981,7 @@ ACCOUNT_INTERNAL_API int account_type_set_label(account_type_h account_type, con
                return ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
-       if (!label || !locale)
+       if (!label || !locale || strlen(label) <= 0 || strlen(locale) <= 0)
                return ACCOUNT_ERROR_INVALID_PARAMETER;
 
        account_type_s *data = (account_type_s *)account_type;
@@ -2016,6 +2017,7 @@ ACCOUNT_INTERNAL_API int account_type_set_provider_feature(account_type_h accoun
 {
        ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("account type handle is null"));
        ACCOUNT_RETURN_VAL((provider_feature != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("provider_feature is null"));
+       ACCOUNT_RETURN_VAL((strlen(provider_feature) > 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("provider_feature is Empty"));
 
        account_type_s *data = (account_type_s *)account_type;