From: Seonah Moon <31679495+SeonahMoon@users.noreply.github.com> Date: Tue, 17 Oct 2023 07:16:24 +0000 (+0900) Subject: [Connection] Fix ASAN crash issue (#5625) X-Git-Tag: accepted/tizen/8.0/unified/20240613.065534~193 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=374afba5d9065d609fcc405b8c175e5e7520543b;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Connection] Fix ASAN crash issue (#5625) --- diff --git a/src/Tizen.Network.Connection/Interop/Interop.Glib.cs b/src/Tizen.Network.Connection/Interop/Interop.Glib.cs new file mode 100644 index 0000000..a4961a7 --- /dev/null +++ b/src/Tizen.Network.Connection/Interop/Interop.Glib.cs @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Glib + { + [DllImport(Libraries.Glib, EntryPoint = "g_free", CallingConvention = CallingConvention.Cdecl)] + internal static extern uint Free(IntPtr data); + } +} diff --git a/src/Tizen.Network.Connection/Interop/Interop.Libraries.cs b/src/Tizen.Network.Connection/Interop/Interop.Libraries.cs index e4c5317..4963b17 100644 --- a/src/Tizen.Network.Connection/Interop/Interop.Libraries.cs +++ b/src/Tizen.Network.Connection/Interop/Interop.Libraries.cs @@ -20,5 +20,6 @@ internal static partial class Interop { public const string Connection = "libcapi-network-connection.so.1"; public const string Libc = "libc.so.6"; + public const string Glib = "libglib-2.0.so.0"; } } diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs index 91503be..7969f7f 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs @@ -63,7 +63,7 @@ namespace Tizen.Network.Connection Log.Error(Globals.LogTag, "It failed to get apn, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); + Interop.Glib.Free(Value); return result; } @@ -112,7 +112,7 @@ namespace Tizen.Network.Connection Log.Error(Globals.LogTag, "It failed to get home url, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); + Interop.Glib.Free(Value); return result; } diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs index a622a28..637f3c0 100644 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs @@ -479,7 +479,7 @@ namespace Tizen.Network.Connection } string result = Marshal.PtrToStringAnsi(ip); - Interop.Libc.Free(ip); + Interop.Glib.Free(ip); Log.Info(Globals.LogTag, "IPAddress " + result + " (" + result.Length + ")"); if (result.Length == 0) { @@ -535,7 +535,7 @@ namespace Tizen.Network.Connection } string result = Marshal.PtrToStringAnsi(ip); - Interop.Libc.Free(ip); + Interop.Glib.Free(ip); return result; } @@ -553,7 +553,7 @@ namespace Tizen.Network.Connection } string result = Marshal.PtrToStringAnsi(mac); - Interop.Libc.Free(mac); + Interop.Glib.Free(mac); return result; } diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs index df518f9..362e10f 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs @@ -196,7 +196,7 @@ namespace Tizen.Network.Connection Log.Error(Globals.LogTag, "It failed to get id of connection profile, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); + Interop.Glib.Free(Value); return result; } } @@ -217,7 +217,7 @@ namespace Tizen.Network.Connection Log.Error(Globals.LogTag, "It failed to get name of connection profile, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); + Interop.Glib.Free(Value); return result; } } @@ -257,7 +257,7 @@ namespace Tizen.Network.Connection Log.Error(Globals.LogTag, "It failed to get network interface name, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); + Interop.Glib.Free(Value); return result; } } @@ -391,7 +391,7 @@ namespace Tizen.Network.Connection Log.Error(Globals.LogTag, "It failed to get proxy address, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); + Interop.Glib.Free(Value); return result; } diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs index ec3ec8f..d9d50c2 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs @@ -353,7 +353,7 @@ namespace Tizen.Network.Connection string addr = Marshal.PtrToStringAnsi(addrPtr); if (addr == null || addr.Length == 0) return DefaultIPAddress(); - Interop.Libc.Free(addrPtr); + Interop.Glib.Free(addrPtr); return System.Net.IPAddress.Parse(addr); } diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs index 6cfbc33..df370be 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs @@ -55,7 +55,7 @@ namespace Tizen.Network.Connection Log.Error(Globals.LogTag, "It failed to create profile handle, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(value); - Interop.Libc.Free(value); + Interop.Glib.Free(value); return result; } } @@ -76,7 +76,7 @@ namespace Tizen.Network.Connection Log.Error(Globals.LogTag, "It failed to get bssid, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(value); - Interop.Libc.Free(value); + Interop.Glib.Free(value); return result; } }