From: Nishant Chaprana Date: Wed, 25 Jul 2018 09:52:06 +0000 (+0530) Subject: [Fix][stack-buffer-overflow] Use gboolean when using g_variant_get for boolean. X-Git-Tag: accepted/tizen/unified/20180726.140742~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fconnectivity%2Fnet-config.git;a=commitdiff_plain;h=fe7130cfd5e0aa33b899d5576900c31bc9845d04 [Fix][stack-buffer-overflow] Use gboolean when using g_variant_get for boolean. Description: g_variant_get API expects reference of gboolean variable in third parameter, and we arepassing reference of bool variable. As per Glib's documentation, gboolean is typecast of int. ================================================================= (Reference: https://people.gnome.org/~desrt/glib-docs/glib-Basic-Types.html#gboolean) gboolean typedef gint gboolean; A standard boolean type. Variables of this type should only contain the value TRUE or FALSE. ================================================================= Change-Id: I84f0120229a2a9eeec976b1785d5cc4d112db534 Signed-off-by: Nishant Chaprana --- diff --git a/gtest/network_state.cpp b/gtest/network_state.cpp index b0e0f11..4fad5c8 100755 --- a/gtest/network_state.cpp +++ b/gtest/network_state.cpp @@ -34,7 +34,7 @@ NetworkState::~NetworkState() } error_e NetworkState::AddRoute(const char *ip, const char *mask, const char *interface, -const char *gateway, int family, bool *result) +const char *gateway, int family, gboolean *result) { GVariant *message = NULL; error_e error = ERROR_NONE; @@ -59,7 +59,7 @@ const char *gateway, int family, bool *result) } error_e NetworkState::RemoveRoute(const char *ip, const char *mask, const char *interface, -const char *gateway, int family, bool *result) +const char *gateway, int family, gboolean *result) { GVariant *message = NULL; error_e error = ERROR_NONE; @@ -212,7 +212,7 @@ error_e NetworkState::DevicePolicyGetWifiProfile(int *state) return ERROR_NONE; } -error_e NetworkState::GetMeteredInfo(bool *state) +error_e NetworkState::GetMeteredInfo(gboolean *state) { GVariant *message = NULL; error_e error = ERROR_NONE; @@ -256,7 +256,7 @@ error_e NetworkState::PreferredIpv6Address(const char *profile, char *address) return ERROR_NONE; } -error_e NetworkState::GetTCPDumpState(bool *state) +error_e NetworkState::GetTCPDumpState(gboolean *state) { GVariant *message = NULL; error_e error = ERROR_NONE; diff --git a/gtest/network_state.h b/gtest/network_state.h index 8d51d2a..7e33fb2 100755 --- a/gtest/network_state.h +++ b/gtest/network_state.h @@ -24,18 +24,18 @@ public: NetworkState(); ~NetworkState(); error_e AddRoute(const char *ip, const char *mask, const char *interface, - const char *gateway, int family, bool *result); + const char *gateway, int family, gboolean *result); error_e RemoveRoute(const char *ip, const char *mask, const char *interface, - const char *gateway, int family, bool *result); + const char *gateway, int family, gboolean *result); error_e EthernetCableState(int *state); error_e LaunchMdns(const char *name); error_e DevicePolicySetWifi(int state); error_e DevicePolicyGetWifi(int *state); error_e DevicePolicySetWifiProfile(int state); error_e DevicePolicyGetWifiProfile(int *state); - error_e GetMeteredInfo(bool *state); + error_e GetMeteredInfo(gboolean *state); error_e PreferredIpv6Address(const char *profile, char *address); - error_e GetTCPDumpState(bool *state); + error_e GetTCPDumpState(gboolean *state); error_e StartTCPDump(); error_e StopTCPDump(); }; diff --git a/gtest/unittest.cpp b/gtest/unittest.cpp index 7db3ff9..679b8a8 100755 --- a/gtest/unittest.cpp +++ b/gtest/unittest.cpp @@ -154,7 +154,7 @@ TEST(NetworkState, AddRoute_p) const char *mask = "255.255.255.0"; const char *interface = "lo"; const char *gateway = "192.168.11.1"; - bool result; + gboolean result; ret = mgr.AddRoute(ip, mask, interface, gateway, AF_INET, &result); @@ -170,7 +170,7 @@ TEST(NetworkState, RemoveRoute_p) const char *mask = "255.255.255.0"; const char *interface = "lo"; const char *gateway = "192.168.11.1"; - bool result; + gboolean result; ret = mgr.RemoveRoute(ip, mask, interface, gateway, AF_INET, &result); @@ -183,7 +183,7 @@ TEST(NetworkState, RemoveRoute_n) { error_e ret = ERROR_NONE; NetworkState mgr; - bool result; + gboolean result; ret = mgr.RemoveRoute(NULL, NULL, NULL, NULL, -1, &result); @@ -306,7 +306,7 @@ TEST(NetworkState, GetMeteredInfo_p) { error_e ret = ERROR_NONE; NetworkState mgr; - bool state; + gboolean state; ret = mgr.GetMeteredInfo(&state); EXPECT_EQ(ERROR_NONE, ret); @@ -316,7 +316,7 @@ TEST(NetworkState, GetMeteredInfo_n) { error_e ret = ERROR_NONE; NetworkState mgr; - bool state; + gboolean state; ret = mgr.GetMeteredInfo(&state); EXPECT_EQ(ERROR_NONE, ret); @@ -326,7 +326,7 @@ TEST(NetworkState, GetTCPDumpState_p) { error_e ret = ERROR_NONE; NetworkState mgr; - bool state; + gboolean state; ret = mgr.GetTCPDumpState(&state); EXPECT_EQ(ERROR_NONE, ret); @@ -345,7 +345,7 @@ TEST(NetworkState, StartTCPDump_p) { error_e ret = ERROR_NONE; NetworkState mgr; - bool state; + gboolean state; ret = mgr.StartTCPDump(); EXPECT_EQ(ERROR_NONE, ret); @@ -361,7 +361,7 @@ TEST(NetworkState, StartTCPDump_n) error_e ret = ERROR_NONE; NetworkState mgr; Wifi wifi_mgr; - bool state; + gboolean state; ret = mgr.StartTCPDump(); EXPECT_EQ(ERROR_NONE, ret); @@ -378,7 +378,7 @@ TEST(NetworkState, StopTCPDump_p) { error_e ret = ERROR_NONE; NetworkState mgr; - bool state; + gboolean state; ret = mgr.StopTCPDump(); EXPECT_EQ(ERROR_NONE, ret); @@ -393,7 +393,7 @@ TEST(NetworkState, StopTCPDump_n) { error_e ret = ERROR_NONE; NetworkState mgr; - bool state; + gboolean state; ret = mgr.StopTCPDump(); EXPECT_EQ(ERROR_NONE, ret); @@ -696,7 +696,7 @@ TEST(WifiTest, IsIpConflictDetectEnabled_p) { error_e ret = ERROR_NONE; Wifi mgr; - bool state; + gboolean state; ret = mgr.IsIpConflictDetectEnabled(&state); EXPECT_EQ(ERROR_NONE, ret); @@ -718,7 +718,7 @@ TEST(WifiTest, GetAutoscan_p) { error_e ret = ERROR_NONE; Wifi mgr; - bool state; + gboolean state; ret = mgr.GetAutoscan(&state); EXPECT_EQ(ERROR_NONE, ret); @@ -1035,7 +1035,7 @@ TEST(WifiTest, IpConflictSetEnable_p) { error_e ret = ERROR_NONE; Wifi mgr; - bool state; + gboolean state; ret = mgr.IsIpConflictDetectEnabled(&state); EXPECT_EQ(ERROR_NONE, ret); @@ -1050,7 +1050,7 @@ TEST(WifiTest, ReqSimAuth_p) Wifi mgr; const unsigned char *rand_data = (unsigned char *)"0123456789012345"; unsigned int length = 16; - bool result; + gboolean result; ret = mgr.ReqSimAuth(rand_data, length, &result); EXPECT_EQ(ERROR_NONE, ret); @@ -1064,7 +1064,7 @@ TEST(WifiTest, ReqSimAuth_n) unsigned char rand[5] = {0, }; const unsigned char *rand_data = (unsigned char *)rand; unsigned int length = 5; - bool result; + gboolean result; ret = mgr.ReqSimAuth(rand_data, length, &result); EXPECT_NE(ERROR_NONE, ret); @@ -1082,7 +1082,7 @@ TEST(WifiTest, ReqAkaAuth_p) const unsigned char *rand_data = (unsigned char *)rand; const unsigned char *auth_data = (unsigned char *)auth; int length = 16; - bool result; + gboolean result; ret = mgr.ReqAkaAuth(rand_data, length, auth_data, length, &result); EXPECT_EQ(ERROR_NONE, ret); @@ -1098,7 +1098,7 @@ TEST(WifiTest, ReqAkaAuth_n) const unsigned char *rand_data = (unsigned char *)rand; const unsigned char *auth_data = (unsigned char *)auth; int length = 5; - bool result; + gboolean result; ret = mgr.ReqAkaAuth(rand_data, length, auth_data, length, &result); EXPECT_NE(ERROR_NONE, ret); @@ -1112,7 +1112,7 @@ TEST(WifiTest, CheckBlackList_p) const char *name = "gtest"; const char *sec_type = "gtest"; const char *eap = "gtest"; - bool allowed; + gboolean allowed; ret = mgr.CheckBlackList(name, sec_type, eap, &allowed); EXPECT_EQ(ERROR_NONE, ret); diff --git a/gtest/wifi.cpp b/gtest/wifi.cpp index 613c05e..261feb3 100755 --- a/gtest/wifi.cpp +++ b/gtest/wifi.cpp @@ -57,7 +57,7 @@ error_e Wifi::GetWifiState(char *state) return ERROR_NONE; } -error_e Wifi::IsIpConflictDetectEnabled(bool *state) +error_e Wifi::IsIpConflictDetectEnabled(gboolean *state) { GVariant *message = NULL; error_e error = ERROR_NONE; @@ -102,7 +102,7 @@ error_e Wifi::SetBgscan(int scan_mode) return ERROR_NONE; } -error_e Wifi::GetAutoscan(bool *state) +error_e Wifi::GetAutoscan(gboolean *state) { GVariant *message = NULL; error_e error = ERROR_NONE; @@ -617,7 +617,7 @@ error_e Wifi::GetSimImsi(char *imsi) } error_e Wifi::ReqSimAuth(const unsigned char *rand_data, unsigned int length, - bool *result) + gboolean *result) { GVariant *message = NULL; error_e error = ERROR_NONE; @@ -649,7 +649,7 @@ error_e Wifi::ReqSimAuth(const unsigned char *rand_data, unsigned int length, } error_e Wifi::ReqAkaAuth(const unsigned char *rand_data, int rand_length, - const unsigned char *autn_data, int auth_length, bool *result) + const unsigned char *autn_data, int auth_length, gboolean *result) { GVariant *message = NULL; error_e error = ERROR_NONE; @@ -717,7 +717,7 @@ error_e Wifi::GetSimAuth(const unsigned char *auth_data, unsigned int length) } error_e Wifi::CheckBlackList(const char *name, const char *sec_type, - const char *eap, bool *allowed) + const char *eap, gboolean *allowed) { GVariant *message = NULL; error_e error = ERROR_NONE; diff --git a/gtest/wifi.h b/gtest/wifi.h index ef0200c..17d3b7a 100755 --- a/gtest/wifi.h +++ b/gtest/wifi.h @@ -25,9 +25,9 @@ public: ~Wifi(); error_e GetWifiState(char *state); -error_e IsIpConflictDetectEnabled(bool *state); +error_e IsIpConflictDetectEnabled(gboolean *state); error_e SetBgscan(int scan_mode); -error_e GetAutoscan(bool *state); +error_e GetAutoscan(gboolean *state); error_e GetIpConflictState(int *state); error_e GetIpConflictPeriod(int *period); error_e GetAutoscanmode(int *autoscanmode); @@ -52,12 +52,12 @@ error_e DeleteEapConfig(const char *profile_name); error_e IpConflictSetEnable(bool detect); error_e GetSimImsi(char *imsi); error_e ReqSimAuth(const unsigned char *rand_data, unsigned int length, - bool *result); + gboolean *result); error_e ReqAkaAuth(const unsigned char *rand_data, int rand_length, - const unsigned char *auth_data, int auth_length, bool *result); + const unsigned char *auth_data, int auth_length, gboolean *result); error_e GetSimAuth(const unsigned char *auth_data, unsigned int length); error_e CheckBlackList(const char *name, const char *sec_type, - const char *eap, bool *allowed); + const char *eap, gboolean *allowed); error_e TdlsDisconnect(const char *peer_mac_address, int *result); error_e TdlsConnectedPeer(char *peer_mac_address); error_e TdlsConnect(const char *peer_mac_address, int *result); diff --git a/packaging/net-config.spec b/packaging/net-config.spec index 64e1b56..ec96264 100755 --- a/packaging/net-config.spec +++ b/packaging/net-config.spec @@ -1,6 +1,6 @@ Name: net-config Summary: TIZEN Network Configuration service -Version: 1.1.135 +Version: 1.1.136 Release: 3 Group: System/Network License: Apache-2.0