Fix some svace issues for memory leak and checking return value 74/197874/1 submit/tizen/20190122.114357 submit/tizen/20190123.120140
authorhyunuktak <hyunuk.tak@samsung.com>
Thu, 17 Jan 2019 01:38:23 +0000 (10:38 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Thu, 17 Jan 2019 01:38:26 +0000 (10:38 +0900)
Change-Id: I515dbd75441176e234a97188762ccaf8af4d3016
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
packaging/net-config.spec
src/ip-conflict-detect.c
src/utils/util.c
src/wifi-power.c

index 800d3d1..930b997 100755 (executable)
@@ -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
index b941e5e..d9712d4 100755 (executable)
@@ -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) {
index d80c743..996b2e7 100755 (executable)
@@ -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);
 }
index 71e9530..947716f 100755 (executable)
@@ -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);