Fixed chances of memory corruption in wifi_manager_get_network_interface_name(). 12/91012/1
authorNishant Chaprana <n.chaprana@samsung.com>
Wed, 5 Oct 2016 09:43:27 +0000 (15:13 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Wed, 5 Oct 2016 09:43:27 +0000 (15:13 +0530)
Description: As per API documentation, mac_address should be freed using free().
But we are using glib allocator for allocating memory.
So, that allocated memory should be freed by g_free() only as per GLIB documentation.

Usage os g_strdup in API may lead to memory corruption, because memory allocated
using g_strdup should be freed using g_free.

So to match declaration in header file for wifi_manager_get_network_interface_name()
we should use strndup in place of g_strdup().

Change-Id: I0dc8df3aaa66f402075c6369964c9ae1919d562f
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
packaging/capi-network-wifi-manager.spec
src/wifi_internal.c
test/wifi_manager_test.c

index e667efb918f487461c2f45479b6eac1927a26e9d..25778c004b0ff90103255700a1af061f72a36cd9 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          capi-network-wifi-manager
 Summary:       Network Wi-Fi library in TIZEN C API
-Version:       1.0.7
+Version:       1.0.8
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
index 22408672b8437415ae734d566d98480a7c23f7b0..ca222370336df8973babe8f090baf4a3b6911707 100755 (executable)
@@ -1071,7 +1071,7 @@ int _wifi_get_intf_name(char** name)
        }
 
        net_profile_info_s *profile = (net_profile_info_s *)profile_iterator->data;
-       *name = g_strdup(profile->net_info.DevName);
+       *name = strdup(profile->net_info.DevName);
        if (*name == NULL)
                return WIFI_MANAGER_ERROR_OUT_OF_MEMORY;
 
index fb04a21bddffd3597931def0d05a70748d74c892..262e6a72a410b8dde9d19223f46601ac4a7800a9 100755 (executable)
@@ -1227,7 +1227,7 @@ int test_wifi_manager_get_interface_name(void)
        }
 
        printf("Interface name : %s\n", if_name);
-       g_free(if_name);
+       free(if_name);
 
        return 1;
 }