fix svace issue 84/173084/2 accepted/tizen/unified/20180320.065829 submit/tizen/20180320.010141
authorsaerome.kim <saerome.kim@samsung.com>
Mon, 19 Mar 2018 11:29:04 +0000 (20:29 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 19 Mar 2018 11:37:48 +0000 (20:37 +0900)
- WID 3137790, 313819, 314741, 315855

Change-Id: I93e058c6beaf5479edf3f33dfa86e38f042d480d
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
src/wmesh-interface.c
src/wmesh-peer-monitor.c
src/wmesh-softap.c

index b4a2e3d..81a8fc2 100644 (file)
@@ -235,12 +235,14 @@ char* wmesh_interface_get_address(const char* if_name)
        snprintf(buf, sizeof(buf), "/sys/class/net/%s/address", if_name);
        pf = fopen(buf, "r");
        if (NULL != pf) {
-               fgets(buf, 31, pf);
-               WMESH_LOGD("Interface[%s] address[%s]", if_name, buf);
-
-               if (strlen(buf) > 0)
-                       result = g_strdup(buf);
+               if (!fgets(buf, 31, pf) || ferror(pf) || feof(pf)) {
+                       WMESH_LOGE("Error open Inerface[%s]", if_name);
+               } else {
+                       WMESH_LOGD("Interface[%s] address[%s]", if_name, buf);
 
+                       if (strlen(buf) > 0)
+                               result = g_strdup(buf);
+               }
                fclose(pf);
        }
 
index 431ae16..87205c9 100644 (file)
@@ -226,7 +226,10 @@ static gboolean _on_mesh_monitor_cb(gpointer pdata)
 #if 0
                        _get_mpath_info(service);
 #endif
-                       _get_station_info(service);
+                       ret = _get_station_info(service);
+                       if (WMESHD_ERROR_NONE != ret) {
+                               WMESH_LOGW("Erro in get station info (%d)", ret);
+                       }
                }
        }
 
index bd96348..a65600a 100644 (file)
@@ -216,7 +216,10 @@ static int __read_hostapd_config(char **softap_interface, char **ssid,
 
        *security = 0;
 
-       while (NULL != fgets(buf, sizeof(buf), fp)) {
+       while (1) {
+               if (!fgets(buf, sizeof(buf), fp) || ferror(fp) || feof(fp))
+                       break;
+
                if (strncmp(buf, "interface", strlen("interface")) == 0) {
                        *softap_interface = g_strdup(strrchr(buf, '=') + 1);
                        WMESH_LOGD("Interface: %s", *softap_interface);
@@ -438,7 +441,12 @@ static int __execute_hostapd()
                /* LCOV_EXCL_STOP */
        } else {
                /* Reap child */
-               waitpid(pid, &status, 0);
+               if (-1 == waitpid(pid, &status, 0)) {
+                       if (errno != EINTR) {
+                               WMESH_LOGE("   Faild to reap child [%d] errono(%d)", pid, errno);
+                               return WMESHD_ERROR_OPERATION_FAILED;
+                       }
+               }
                WMESH_LOGD("  child [%d] reaped with status(%d)", pid, status);
        }