Validate the ESSID before use 59/193459/1 accepted/tizen/unified/20181129.054220 submit/tizen/20181127.113629
authorJaehyun Kim <jeik01.kim@samsung.com>
Wed, 21 Nov 2018 03:58:08 +0000 (12:58 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Wed, 21 Nov 2018 04:00:05 +0000 (13:00 +0900)
Change-Id: I2c2041305d2e20aebc4d5a6fe1255df8686877c8
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
include/wifi_internal.h
src/wifi_ap.c
src/wifi_config.c
src/wifi_internal.c
src/wifi_manager.c

index c581d16..7a48dbd 100755 (executable)
@@ -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);
index 8098222..4f065d6 100755 (executable)
@@ -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
index 3037525..4f2868d 100755 (executable)
@@ -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__;
index f54af56..cbc58d2 100755 (executable)
@@ -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;
index 95692e4..b316b74 100755 (executable)
@@ -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