From 5a4e18bd63a721f75ea9dd6d4b98732f8025a691 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Tue, 5 May 2020 00:05:53 +0900 Subject: [PATCH] Fixed null dereferencing Change-Id: Ie0a6e25b568109369d36041f68a4a0dcb3e13688 Signed-off-by: Jaehyun Kim --- src/connection_profile.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/connection_profile.c b/src/connection_profile.c index 8122d25..4f884ea 100755 --- a/src/connection_profile.c +++ b/src/connection_profile.c @@ -2702,6 +2702,12 @@ EXPORT_API int connection_profile_enable_ethernet_eap(connection_profile_h profi net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); + if (!net_info) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); + CONN_UNLOCK; + return CONNECTION_ERROR_INVALID_OPERATION; + } + int ret = _connection_libnet_enable_ethernet_eap(enable, net_info->ProfileName); if (ret != CONNECTION_ERROR_NONE) { CONNECTION_LOG(CONNECTION_ERROR, "Failed to enable EAP over ethernet"); @@ -2732,7 +2738,7 @@ EXPORT_API int connection_profile_set_ethernet_eap_type(connection_profile_h pro net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info->use_eapol == false) { + if (!net_info || net_info->use_eapol == false) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -2760,7 +2766,7 @@ EXPORT_API int connection_profile_get_ethernet_eap_type(connection_profile_h pro net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info->use_eapol == false) { + if (!net_info || net_info->use_eapol == false) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -2790,7 +2796,7 @@ EXPORT_API int connection_profile_set_ethernet_eap_passphrase(connection_profile net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_passphrase(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_passphrase(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -2821,7 +2827,7 @@ EXPORT_API int connection_profile_get_ethernet_eap_passphrase(connection_profile net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_passphrase(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_passphrase(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -2860,7 +2866,7 @@ EXPORT_API int connection_profile_set_ethernet_eap_identity(connection_profile_h net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_identity(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_identity(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -2890,7 +2896,7 @@ EXPORT_API int connection_profile_get_ethernet_eap_identity(connection_profile_h net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_identity(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_identity(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -2924,7 +2930,7 @@ EXPORT_API int connection_profile_set_ethernet_eap_ca_cert_file(connection_profi net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_ca_cert_file(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_ca_cert_file(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -2954,7 +2960,7 @@ EXPORT_API int connection_profile_get_ethernet_eap_ca_cert_file(connection_profi net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_ca_cert_file(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_ca_cert_file(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -2988,7 +2994,7 @@ EXPORT_API int connection_profile_set_ethernet_eap_client_cert_file(connection_p net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_client_cert_file(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_client_cert_file(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -3018,7 +3024,7 @@ EXPORT_API int connection_profile_get_ethernet_eap_client_cert_file(connection_p net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_client_cert_file(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_client_cert_file(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -3052,7 +3058,7 @@ EXPORT_API int connection_profile_get_ethernet_eap_private_key_file(connection_p net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_private_key_file(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_private_key_file(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -3086,7 +3092,7 @@ EXPORT_API int connection_profile_set_ethernet_eap_private_key_info(connection_p net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_private_key_file(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_private_key_file(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -3117,7 +3123,7 @@ EXPORT_API int connection_profile_set_ethernet_eap_anonymous_identity(connection net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_anonymous_identity(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_anonymous_identity(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -3147,7 +3153,7 @@ EXPORT_API int connection_profile_get_ethernet_eap_anonymous_identity(connection net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_anonymous_identity(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_anonymous_identity(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -3181,7 +3187,7 @@ EXPORT_API int connection_profile_set_ethernet_eap_pac_file(connection_profile_h net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_pac_file(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_pac_file(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -3211,7 +3217,7 @@ EXPORT_API int connection_profile_get_ethernet_eap_pac_file(connection_profile_h net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_pac_file(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_pac_file(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -3244,7 +3250,7 @@ EXPORT_API int connection_profile_set_ethernet_eap_auth_type(connection_profile_ net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_auth_type(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_auth_type(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -3273,7 +3279,7 @@ EXPORT_API int connection_profile_get_ethernet_eap_auth_type(connection_profile_ net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_auth_type(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_auth_type(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -3302,7 +3308,7 @@ EXPORT_API int connection_profile_set_ethernet_eap_peap_version(connection_profi net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_peap_version(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_peap_version(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; @@ -3330,7 +3336,7 @@ EXPORT_API int connection_profile_get_ethernet_eap_peap_version(connection_profi net_profile_info_t *profile_info = profile; net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (false == __profile_ethernet_validate_eap_peap_version(net_info)) { + if (!net_info || false == __profile_ethernet_validate_eap_peap_version(net_info)) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); CONN_UNLOCK; return CONNECTION_ERROR_INVALID_OPERATION; -- 2.7.4