Fix the prevent issues 16/196616/1 accepted/tizen/4.0/unified/20190103.235212 submit/tizen_4.0/20190103.044435
authorDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 3 Jan 2019 04:13:52 +0000 (13:13 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 3 Jan 2019 04:13:52 +0000 (13:13 +0900)
Change-Id: Id80406608822576a387052dbb462d86283742ae3
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-ipsp/bt-ipsp.c
map-agent/bluetooth_map_agent.c
map-agent/bluetooth_map_email.c

index 246e36d..4ec188d 100644 (file)
@@ -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("-");
index 1d1087d..b3a0015 100644 (file)
@@ -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;
index 80d2124..1e974b5 100644 (file)
@@ -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;