From 91d6337cbe2ffe259065d141dcf93237c003f057 Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Fri, 31 Mar 2017 16:28:17 +0900 Subject: [PATCH] Fixed some svace issues WGID : 79378, 148142, 149574, 167281 Change-Id: I639ea68254b8f0cdaf7c49f21b2cee201b9a2ff7 Signed-off-by: hyunuktak --- src/vpnsvc-internal.c | 2 +- src/wifi-agent.c | 2 +- src/wifi-config.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/vpnsvc-internal.c b/src/vpnsvc-internal.c index 5f7e3f1..1ccfcbf 100755 --- a/src/vpnsvc-internal.c +++ b/src/vpnsvc-internal.c @@ -632,7 +632,7 @@ static int get_interface_index(const char *iface_name) memset(&ifr, 0, sizeof(ifr)); if (*iface_name) - strncpy(ifr.ifr_name, iface_name, strlen(iface_name)); + strncpy(ifr.ifr_name, iface_name, IFNAMSIZ); /* get an interface name by ifindex */ if (ioctl(sk, SIOCGIFINDEX, &ifr) < 0) { diff --git a/src/wifi-agent.c b/src/wifi-agent.c index 2d3c745..b2dd9d7 100755 --- a/src/wifi-agent.c +++ b/src/wifi-agent.c @@ -127,7 +127,7 @@ gboolean netconfig_wifi_set_agent_field_for_eap_network( name_len = strlen(name); agent.ssid = g_byte_array_sized_new(name_len); agent.ssid->len = name_len; - memcpy(agent.ssid->data, name, name_len); + memcpy(agent.ssid->data, name, name_len + 1); if (identity) agent.identity = g_strdup(identity); diff --git a/src/wifi-config.c b/src/wifi-config.c index aa2ab05..1f479a3 100755 --- a/src/wifi-config.c +++ b/src/wifi-config.c @@ -543,6 +543,7 @@ static gboolean _get_field(const gchar *config_id, const gchar *key, gchar **val static GSList *_get_list(void) { GSList *list = NULL; + struct dirent de; struct dirent *dp = NULL; DIR *dir; @@ -552,7 +553,7 @@ static GSList *_get_list(void) return NULL; } - while ((dp = readdir(dir)) != NULL) { + while ((readdir_r(dir, &de, &dp) == 0) && (dp != NULL)) { if (g_strcmp0(dp->d_name, ".") == 0 || g_strcmp0(dp->d_name, "..") == 0 || strncmp(dp->d_name, WIFI_CONFIG_PREFIX, strlen(WIFI_CONFIG_PREFIX)) != 0) { continue; -- 2.7.4