Check length of input param for preventing from Empty 81/112281/3 accepted/tizen/3.0/common/20170210.172440 accepted/tizen/3.0/ivi/20170210.095221 accepted/tizen/3.0/mobile/20170210.095103 accepted/tizen/3.0/wearable/20170210.095205 submit/tizen_3.0/20170210.054336
authorJooseok Song <seogii.song@samsung.com>
Tue, 31 Jan 2017 03:48:00 +0000 (12:48 +0900)
committerJooseok Song <seogii.song@samsung.com>
Tue, 31 Jan 2017 04:24:34 +0000 (13:24 +0900)
Change-Id: Ia75dfe05a80c6f960cb4f22a0f9912a13d61c0fc

src/account.c

index 7d54ff5..aeb8783 100644 (file)
@@ -634,8 +634,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;
        }
 
@@ -658,8 +658,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;
        }
 
@@ -682,8 +682,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;
        }
 
@@ -706,8 +706,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;
        }
 
@@ -730,8 +730,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;
@@ -753,8 +753,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;
        }
 
@@ -777,8 +777,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;
@@ -800,8 +800,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;
        }
 
@@ -824,8 +824,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) {
@@ -852,12 +852,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;
        }
@@ -994,6 +994,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;
@@ -1891,8 +1892,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;
        }
 
@@ -1913,7 +1914,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;
@@ -1933,7 +1934,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;
@@ -1953,7 +1954,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;
@@ -1986,7 +1987,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;
@@ -2022,6 +2023,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;