From: hyunuktak Date: Thu, 17 Jan 2019 01:38:23 +0000 (+0900) Subject: Fix some svace issues for memory leak and checking return value X-Git-Tag: submit/tizen/20190122.114357^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4933bfde80e20fa3cb4963c7d7f9add022ebf0c0;hp=-c;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git Fix some svace issues for memory leak and checking return value Change-Id: I515dbd75441176e234a97188762ccaf8af4d3016 Signed-off-by: hyunuktak --- 4933bfde80e20fa3cb4963c7d7f9add022ebf0c0 diff --git a/packaging/net-config.spec b/packaging/net-config.spec index 800d3d1..930b997 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.140 +Version: 1.1.141 Release: 3 Group: System/Network License: Apache-2.0 diff --git a/src/ip-conflict-detect.c b/src/ip-conflict-detect.c index b941e5e..d9712d4 100755 --- a/src/ip-conflict-detect.c +++ b/src/ip-conflict-detect.c @@ -309,10 +309,8 @@ static gboolean send_arp(gpointer data) INFO("Sending ARP Packet Failed. Error. = %s\n", strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER)); /* close socket */ - if (-1 < sd->chk_conflict_sd) { - close(sd->chk_conflict_sd); - sd->chk_conflict_sd = -1; - } + close(sd->chk_conflict_sd); + sd->chk_conflict_sd = -1; /* reopen socket */ if ((sd->chk_conflict_sd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ARP))) == -1) { diff --git a/src/utils/util.c b/src/utils/util.c index d80c743..996b2e7 100755 --- a/src/utils/util.c +++ b/src/utils/util.c @@ -147,8 +147,10 @@ void netconfig_keyfile_save(GKeyFile *keyfile, const char *pathname) g_error_free(error); } - chmod(pathname, S_IRUSR | S_IWUSR); - DBG("Successfully saved keyfile %s", pathname); + if (chmod(pathname, S_IRUSR | S_IWUSR) < 0) + DBG("Failed to change mode"); + else + DBG("Successfully saved keyfile %s", pathname); g_free(keydata); } diff --git a/src/wifi-power.c b/src/wifi-power.c index 71e9530..947716f 100755 --- a/src/wifi-power.c +++ b/src/wifi-power.c @@ -307,11 +307,19 @@ static void __netconfig_set_wifi_bssid(void) return; } - fseek(fp, 0L, SEEK_SET); - rv = fscanf(fp, "%17s", bssid); + rv = fseek(fp, 0L, SEEK_SET); + if (rv != 0) { + ERR("Fail to seek file"); + fclose(fp); + return; + } - if (rv < 0) + rv = fscanf(fp, "%17s", bssid); + if (rv < 0) { ERR("Fail to read bssid"); + fclose(fp); + return; + } netconfig_set_vconf_str(VCONF_WIFI_BSSID_ADDRESS, bssid);