Prevent issue fix 67/49767/1 accepted/tizen/mobile/20151020.110841 accepted/tizen/tv/20151020.110845 accepted/tizen/wearable/20151020.110858 submit/tizen/20151020.063015
authorHaejeong, Kim <backto.kim@samsung.com>
Tue, 20 Oct 2015 06:01:30 +0000 (15:01 +0900)
committerHaejeong, Kim <backto.kim@samsung.com>
Tue, 20 Oct 2015 06:01:30 +0000 (15:01 +0900)
Change-Id: I18887b04f04dd5b86a0390d5f55221e178715cb1

lib/media-util-cynara.c
lib/media-util-ipc.c
packaging/media-server.spec
src/scanner/media-scanner-scan.c
src/server/media-server-thumb.c

index 2ab9f03..defe3a1 100755 (executable)
@@ -152,9 +152,11 @@ int ms_cynara_receive_untrusted_message_thumb(int sockfd, thumbMsg *recv_msg, ms
        if ((recv_msg_size = recv(sockfd, buf, header_size, 0)) < 0) {
                if (errno == EWOULDBLOCK) {
                        MSAPI_DBG_ERR("Timeout. Can't try any more");
+                       MS_SAFE_FREE(buf);
                        return MS_MEDIA_ERR_SOCKET_RECEIVE_TIMEOUT;
                } else {
                        MSAPI_DBG_ERR("recv failed");
+                       MS_SAFE_FREE(buf);
                        return MS_MEDIA_ERR_SOCKET_RECEIVE;
                }
        }
index f03a18a..f09aca4 100755 (executable)
@@ -123,7 +123,7 @@ int ms_ipc_create_client_socket(ms_protocol_e protocol, int timeout_sec, ms_sock
                serv_addr.sun_family = AF_UNIX;
                MSAPI_DBG("%s", sock_info->sock_path);
                unlink(sock_info->sock_path);
-               strcpy(serv_addr.sun_path, sock_info->sock_path);
+               strncpy(serv_addr.sun_path, sock_info->sock_path, strlen(sock_info->sock_path));
 
                /* Bind to the local address */
                if (bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
index 1705f09..9802eba 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       media-server
 Summary:    File manager service server.
-Version:    0.2.60
+Version:    0.2.61
 Release:    0
 Group:      Multimedia/Service
 License:    Apache-2.0
index 0400d25..f86a517 100755 (executable)
@@ -1261,6 +1261,7 @@ static int __msc_check_ignore_dir(const char *full_path, uid_t uid)
        int ret = MS_MEDIA_ERR_NONE;
        char *dir_path = NULL;
        char *leaf_path = NULL;
+       char *usr_path = NULL;
 
        ret = __msc_check_file_path(full_path, uid);
        if (ret != MS_MEDIA_ERR_NONE) {
@@ -1275,6 +1276,13 @@ static int __msc_check_ignore_dir(const char *full_path, uid_t uid)
                return MS_MEDIA_ERR_INVALID_PATH;
        }
 
+       usr_path = __msc_get_path(uid);
+       if (usr_path == NULL) {
+               MS_DBG_ERR("__msc_get_path() fail");
+               MS_SAFE_FREE(dir_path);
+               return MS_MEDIA_ERR_INTERNAL;
+       }
+
        while (1) {
                if (__msc_check_scan_ignore(dir_path)) {
                        ret = MS_MEDIA_ERR_INVALID_PATH;
@@ -1282,7 +1290,7 @@ static int __msc_check_ignore_dir(const char *full_path, uid_t uid)
                }
 
                /*If root path, Stop Scanning*/
-               if (strcmp(dir_path, __msc_get_path(uid)) == 0)
+               if (strcmp(dir_path, usr_path) == 0)
                        break;
                else if (MS_STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && (strcmp(dir_path, MEDIA_ROOT_PATH_SDCARD) == 0))
                        break;
@@ -1301,6 +1309,7 @@ static int __msc_check_ignore_dir(const char *full_path, uid_t uid)
        }
 
        MS_SAFE_FREE(dir_path);
+       MS_SAFE_FREE(usr_path);
 
        return ret;
 }
@@ -1688,11 +1697,19 @@ gboolean msc_metadata_update(void *data)
        ms_update_start(handle);
 
        /*insert data into media db */
-       start_path = strdup(__msc_get_path(scan_data->uid));
+       char *usr_path = __msc_get_path(scan_data->uid);
+       if (usr_path == NULL) {
+               MS_DBG_ERR("__msc_get_path() fail");
+               if (handle) ms_disconnect_db(&handle);
+               return MS_MEDIA_ERR_INTERNAL;
+       }
+
+       start_path = strdup(usr_path);
        ret = __msc_dir_scan_meta_update(handle, start_path, storage_type, scan_data->uid);
+       MS_SAFE_FREE(usr_path);
 
        /* send notification */
-       ms_send_dir_update_noti(handle, INTERNAL_STORAGE_ID, __msc_get_path(scan_data->uid), NULL, MS_ITEM_UPDATE, scan_data->pid);
+       ms_send_dir_update_noti(handle, INTERNAL_STORAGE_ID, start_path, NULL, MS_ITEM_UPDATE, scan_data->pid);
 
        if (mmc_state == MS_STG_INSERTED) {
                storage_type = MS_STORAGE_EXTERNAL;
index baf6bd3..c1c56e5 100755 (executable)
@@ -360,6 +360,7 @@ gboolean _ms_thumb_agent_recv_msg_from_server()
        recv_msg_size = ms_ipc_receive_message(sockfd, & recv_msg, sizeof(ms_thumb_server_msg));
        if (recv_msg_size != MS_MEDIA_ERR_NONE) {
                MS_DBG_STRERROR("ms_ipc_receive_message failed");
+               close(sockfd);
                return FALSE;
        }