From c35ec81e2be248254b4f32bca68d0f9e517e359d Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Fri, 10 May 2024 17:13:55 +0900 Subject: [PATCH] Fix null dereferencing and unchecked return value Change-Id: I2c847e01661c66cdb76bc474b57b3929c73462e8 Signed-off-by: Jaehyun Kim --- src/connection.c | 2 +- unittest/utc-network-connection.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/connection.c b/src/connection.c index a56230c..8def171 100755 --- a/src/connection.c +++ b/src/connection.c @@ -551,7 +551,7 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty } /* Checking Invalid MAC Address */ - if ((strcmp(*mac_addr, "00:00:00:00:00:00") == 0) || + if (*mac_addr == NULL || (strcmp(*mac_addr, "00:00:00:00:00:00") == 0) || (strcmp(*mac_addr, "ff:ff:ff:ff:ff:ff") == 0)) { CONNECTION_LOG(CONNECTION_ERROR, "MAC Address(%s) is invalid", *mac_addr); //LCOV_EXCL_LINE CONN_UNLOCK; //LCOV_EXCL_LINE diff --git a/unittest/utc-network-connection.c b/unittest/utc-network-connection.c index fd1ae89..2a4748e 100755 --- a/unittest/utc-network-connection.c +++ b/unittest/utc-network-connection.c @@ -2316,8 +2316,9 @@ int utc_connection_open_profile_n(void) int utc_connection_reset_profile_p(void) { if (telephony_supported) { - connection_reset_profile(connection, CONNECTION_RESET_DEFAULT_PROFILE, + int ret = connection_reset_profile(connection, CONNECTION_RESET_DEFAULT_PROFILE, 0, test_connection_reset_profile_callback, NULL); + CHECK_RETURN(CALLBACK_RETURN, ret, CONNECTION_ERROR_NONE); CHECK_RETURN(CALLBACK_RETURN, g_CallbackRet, CONNECTION_ERROR_NONE); test_connection_reset_profile_callback(CONNECTION_ERROR_NONE, NULL); } else { -- 2.7.4