From 23b5db5ee4d83aa86714957ee3088978fb07f124 Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Thu, 3 Jan 2019 13:13:52 +0900 Subject: [PATCH] Fix the prevent issues Change-Id: Id80406608822576a387052dbb462d86283742ae3 Signed-off-by: DoHyun Pyun --- bt-ipsp/bt-ipsp.c | 9 +++++++-- map-agent/bluetooth_map_agent.c | 24 +++++++++++++++++++++--- map-agent/bluetooth_map_email.c | 9 +++++++-- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/bt-ipsp/bt-ipsp.c b/bt-ipsp/bt-ipsp.c index 246e36d..4ec188d 100644 --- a/bt-ipsp/bt-ipsp.c +++ b/bt-ipsp/bt-ipsp.c @@ -705,7 +705,7 @@ static void __bt_ipsp_dbus_method(GDBusConnection *connection, BT_DBG(""); char *ifname = NULL; char *address = NULL; - char *ip6; + char *ip6 = NULL; gchar *network_ipv6_address = NULL; char *remote_ipv6_address = NULL; @@ -724,11 +724,15 @@ static void __bt_ipsp_dbus_method(GDBusConnection *connection, if (ret != BT_ERROR_NONE) BT_DBG("failed to set ipv6 address"); + g_free(ip6); + ret = __bt_ipsp_create_ipv6_remote_address(address, &remote_ipv6_address); if (ret != BT_ERROR_NONE) BT_DBG("failed to create remote device ipv6 address"); __bt_ipsp_get_network_interface_name(&network_interface); + + if (network_interface) __bt_ipsp_get_network_ipv6_address(network_interface, MOBILE_AP_IPV6_SCOPE_GLOBAL, &network_ipv6_address); /* Add the Routing Rule */ @@ -740,7 +744,8 @@ static void __bt_ipsp_dbus_method(GDBusConnection *connection, __bt_ipsp_add_ipv6_route(network_interface, network_ipv6_address, 64); g_free(network_ipv6_address); - + g_free(remote_ipv6_address); + g_free(network_interface); } BT_DBG("-"); diff --git a/map-agent/bluetooth_map_agent.c b/map-agent/bluetooth_map_agent.c index 1d1087d..b3a0015 100644 --- a/map-agent/bluetooth_map_agent.c +++ b/map-agent/bluetooth_map_agent.c @@ -595,9 +595,27 @@ time_t _get_time_t_from_timestamp(char *timestamp) int month; time_t int_time; - sscanf(timestamp, "%04d%02d%02dT%02d%02d%02d", &year, &month, - &local_time.tm_mday, &local_time.tm_hour, - &local_time.tm_min, &local_time.tm_sec); + int ymd; /* year, month, day */ + int hms; /* hour, min, sec */ + char *ptr, *ptr2; + + ymd = strtol(timestamp, &ptr, 10); + hms = strtol(ptr + 1, &ptr2, 10); + + /* Initialize local_time */ + memset(&local_time, 0, sizeof(struct tm)); + + /* parse year, month, day */ + local_time.tm_mday = ymd % 100; + ymd = (ymd - local_time.tm_mday) / 100; + month = ymd % 100; + year = (ymd - month) / 100; + + /* parse hour, minute, sec */ + local_time.tm_sec = hms % 100; + hms = (hms - local_time.tm_sec) / 100; + local_time.tm_min = hms % 100; + local_time.tm_hour = (hms - local_time.tm_min) / 100; local_time.tm_year = year - 1900; local_time.tm_mon = month - 1; diff --git a/map-agent/bluetooth_map_email.c b/map-agent/bluetooth_map_email.c index 80d2124..1e974b5 100644 --- a/map-agent/bluetooth_map_email.c +++ b/map-agent/bluetooth_map_email.c @@ -744,15 +744,20 @@ static char *__bt_prepare_email_bmseg(email_mail_data_t *mail_data) if (body_file != NULL) { fseek(body_file, 0, SEEK_END); email_size = ftell(body_file); + if (email_size <= 0) { + ERR("email_size is not a positive number"); + g_string_free(msg, TRUE); + fclose(body_file); + return NULL; + } rewind(body_file); - buf = (char *)g_malloc0(sizeof(char) * email_size); + buf = (char *)g_malloc0(sizeof(char) * (email_size + 1)); read_size = fread(buf, 1, email_size, body_file); fclose(body_file); DBG("MESSAGE: [%s]", buf); if (read_size != email_size) { ERR("Unequal Read size"); - email_free_mail_data(&mail_data, 1); g_string_free(msg, TRUE); g_free(buf); return NULL; -- 2.7.4