From: Jaehyun Kim Date: Wed, 21 Nov 2018 03:58:08 +0000 (+0900) Subject: Validate the ESSID before use X-Git-Tag: accepted/tizen/unified/20181129.054220^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09974ed37501e06078484f8a429d0148ebf38844;p=platform%2Fcore%2Fapi%2Fwifi-manager.git Validate the ESSID before use Change-Id: I2c2041305d2e20aebc4d5a6fe1255df8686877c8 Signed-off-by: Jaehyun Kim --- diff --git a/include/wifi_internal.h b/include/wifi_internal.h index c581d16..7a48dbd 100755 --- a/include/wifi_internal.h +++ b/include/wifi_internal.h @@ -265,6 +265,7 @@ bool _wifi_check_ap_validity(wifi_manager_ap_h ap_h); void _wifi_add_to_ap_list(wifi_manager_ap_h ap_h); void _wifi_remove_from_ap_list(wifi_manager_ap_h ap_h); bool _wifi_check_profile_name_validity(const char *profile_name); +bool _wifi_check_essid_validity(const char *essid); int _wifi_get_wifi_device_state(wifi_manager_device_state_e *device_state); int _wifi_get_wifi_state(wifi_manager_connection_state_e* connection_state); diff --git a/src/wifi_ap.c b/src/wifi_ap.c index 8098222..4f065d6 100755 --- a/src/wifi_ap.c +++ b/src/wifi_ap.c @@ -309,7 +309,7 @@ EXPORT_API int wifi_manager_ap_create(wifi_manager_h wifi, RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__); - if (essid == NULL || ap == NULL) { + if (!_wifi_check_essid_validity(essid) || ap == NULL) { WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE diff --git a/src/wifi_config.c b/src/wifi_config.c index 3037525..4f2868d 100755 --- a/src/wifi_config.c +++ b/src/wifi_config.c @@ -32,6 +32,11 @@ EXPORT_API int wifi_manager_config_create(wifi_manager_h wifi, const char *name, RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__); + if (!_wifi_check_essid_validity(name)) { + __NETWORK_CAPI_FUNC_EXIT__; + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + } + h = g_new0(wifi_config_s, 1); if (h == NULL) { __NETWORK_CAPI_FUNC_EXIT__; diff --git a/src/wifi_internal.c b/src/wifi_internal.c index f54af56..cbc58d2 100755 --- a/src/wifi_internal.c +++ b/src/wifi_internal.c @@ -1704,6 +1704,24 @@ bool _wifi_check_profile_name_validity(const char *profile_name) return true; } +bool _wifi_check_essid_validity(const char *essid) +{ + int essid_len = 0; + + if (essid == NULL) + return false; + + essid_len = strlen(essid); + + if (essid_len < 1 || essid_len > 32) + return false; + + if (!g_utf8_validate(essid, -1, NULL)) + return false; + + return true; +} + int _wifi_get_wifi_device_state(wifi_manager_device_state_e *device_state) { net_tech_info_s tech_info; diff --git a/src/wifi_manager.c b/src/wifi_manager.c index 95692e4..b316b74 100755 --- a/src/wifi_manager.c +++ b/src/wifi_manager.c @@ -1717,7 +1717,7 @@ EXPORT_API int wifi_manager_specific_scan_set_ssid(wifi_manager_specific_scan_h CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); if (!(_wifi_check_multi_scan_validity(specific_scan)) || - essid == NULL) { + !(_wifi_check_essid_validity(essid))) { WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE