[svace] browser-provider issue fixed. 30/88430/3 accepted/tizen/mobile/20160921.233152 accepted/tizen/tv/20160921.233121 submit/tizen_common/20160923.052709 submit/tizen_mobile/20160921.082004 submit/tizen_tv/20160921.082016
authorLim DoHyung <delight.lim@samsung.com>
Mon, 19 Sep 2016 04:51:53 +0000 (13:51 +0900)
committerLim DoHyung <delight.lim@samsung.com>
Wed, 21 Sep 2016 07:43:16 +0000 (16:43 +0900)
Change-Id: I3d9ac29f92db6468d5d1331f7e6a0e6eee801896
Signed-off-by: Lim DoHyung <delight.lim@samsung.com>
bookmark-adaptor/bookmark-adaptor.c
bookmark-csc-adaptor/bookmark-csc-adaptor.c
common-adaptor/common-adaptor.c
common-adaptor/include/common-adaptor.h
history-adaptor/history-adaptor.c
provider/browser-provider-requests.c
tab-adaptor/tab-adaptor.c

index 97792ec9f57454b8ba20e0832611a43db1758823..da0144bf03d4d347761061ce1e405f020deb6d48 100755 (executable)
@@ -95,7 +95,11 @@ int __browser_adaptor_connect(int callback)
        }
        g_bp_command.cmd = BP_CMD_NONE;
        g_bp_command.id = -1;
-       g_bp_command.cid = g_adaptorinfo->cid;
+       if(g_adaptorinfo != NULL) {
+           g_bp_command.cid = g_adaptorinfo->cid;
+       } else {
+           g_bp_command.cid = 0;
+       }
        if (callback == 1 && g_adaptor_event_thread_pid <= 0) {
                // create thread here ( getting event_socket )
                if (pthread_create(&g_adaptor_event_thread_pid, NULL,
@@ -1007,7 +1011,7 @@ static int __bp_bookmark_adaptor_get_cond_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count > 0) {
+       if (ids_count < 256 && ids_count > 0) {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;
@@ -1152,7 +1156,7 @@ int bp_bookmark_adaptor_get_timestamp_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count > 0) {
+       if (ids_count < 256 && ids_count > 0) {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;
@@ -1257,7 +1261,7 @@ int bp_bookmark_adaptor_get_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count > 0) {
+       if (ids_count < 256 && ids_count > 0) {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;
index 1fafa73ff6321081d4fa163089c72e16577442bf..6a00629fd95d1fbba2b79265f4a6d70b812a06b8 100755 (executable)
@@ -110,6 +110,7 @@ static int __bp_bookmark_csc_get_ids_p
 
        BP_CSC_CHECK_PROVIDER_STATUS;
 
+       pthread_mutex_lock(&g_adaptor_mutex);
        int sock = BP_CHECK_IPC_SOCK;
        bp_command_fmt *cmd = &g_bp_command;
 
@@ -160,7 +161,10 @@ static int __bp_bookmark_csc_get_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count > 0) {
+       if(ids_count >= 256 || ids_count <= 0) {
+           pthread_mutex_unlock(&g_adaptor_mutex);
+           return -1;
+       } else {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;
@@ -203,6 +207,7 @@ int __bp_bookmark_csc_get_retrieved_ids_p
 
        BP_CSC_CHECK_PROVIDER_STATUS;
 
+       pthread_mutex_lock(&g_adaptor_mutex);
        int sock = BP_CHECK_IPC_SOCK;
        bp_command_fmt *cmd = &g_bp_command;
 
@@ -258,7 +263,7 @@ int __bp_bookmark_csc_get_retrieved_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count > 0) {
+       if (ids_count < 256 && ids_count > 0) {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;
@@ -310,7 +315,11 @@ int bookmark_csc_initialize(void)
                }
                g_bp_command.cmd = BP_CMD_NONE;
                g_bp_command.id = -1;
-               g_bp_command.cid = g_adaptorinfo->cid;
+               if(g_adaptorinfo != NULL) {
+                   g_bp_command.cid = g_adaptorinfo->cid;
+               } else {
+                   g_bp_command.cid = 0;
+               }
        }
        pthread_mutex_unlock(&g_adaptor_mutex);
        return 0;
index 05c0262ea9093c1a7f9310eb8236b82e33544f68..f2137292988831680d85fc8898256c1e505219cc 100755 (executable)
@@ -246,7 +246,7 @@ int bp_common_adaptor_get_ids_p(const int sock, bp_command_fmt *cmd,
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count > 0) {
+       if (ids_count < 256 && ids_count > 0) {
                idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        TRACE_ERROR("[CRITICAL] allocation");
@@ -411,7 +411,7 @@ int bp_common_adaptor_get_blob(const int sock, bp_command_fmt *cmd,
                BP_PRINT_ERROR(cmd->id, *errorcode);
                return -1;
        }
-       if (blob_length > 0) {
+       if (blob_length < 256 || blob_length > 0) {
                blob_data =
                        (unsigned char *)calloc(blob_length, sizeof(unsigned char));
                if (blob_data == NULL) {
@@ -503,8 +503,8 @@ int bp_common_adaptor_get_info_blob(int sock, unsigned char **value,
        bp_shm_defs *shm)
 {
        int length = 0;
-       if (bp_ipc_read_custom_type(sock, &length,
-                       sizeof(int)) == 0 && length > 0) {
+       if ((bp_ipc_read_custom_type(sock, &length,
+                       sizeof(int)) == 0) && (length > 0 || length < 256)) {
 
                int trans_way = 0; // 0:socket 1:shm
                if (bp_ipc_read_custom_type(sock, &trans_way,
@@ -562,7 +562,7 @@ int bp_common_adaptor_get_blob_shm(const int sock,
                return -1;
        }
 
-       if (blob_length > 0) {
+       if (blob_length < 256 || blob_length > 0) {
 
                // read here what IPC should be used below from provider.
                int trans_way = 0; // 0:socket 1:shm
index 9eb7134757f436f7739214fe6fea8d35ed8a1155..93178dc19fb527fe60fe78db42993a0046841fa4 100755 (executable)
@@ -95,7 +95,6 @@ int bp_common_adaptor_is_sync_adaptor(void);
 int bp_common_adaptor_disconnect(bp_adaptor_defs **info, pthread_t *tid);
 int bp_common_adaptor_clear_read_buffer(int sock, size_t length);
 
-
 // Statement Macro
 #define BP_CHECK_PROVIDER_STATUS do {\
        pthread_mutex_lock(&g_adaptor_mutex);\
index 0f966a0887ed0612aca81f86408dcf791192b61d..b975335bc35a98034b36bf3aa86dcdc333f2cebe 100755 (executable)
@@ -88,7 +88,11 @@ static int __browser_adaptor_connect(int callback)
        }
        g_bp_command.cmd = BP_CMD_NONE;
        g_bp_command.id = -1;
-       g_bp_command.cid = g_adaptorinfo->cid;
+       if(g_adaptorinfo != NULL) {
+           g_bp_command.cid = g_adaptorinfo->cid;
+       } else {
+           g_bp_command.cid = 0;
+       }
        if (callback == 1 && g_adaptor_event_thread_pid <= 0) {
                // create thread here ( getting event_socket )
                if (pthread_create(&g_adaptor_event_thread_pid, NULL,
@@ -862,8 +866,8 @@ static int __bp_history_adaptor_get_cond_ids_p
        }
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
-       TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count > 0) {
+       TRACE_ERROR("response ids count:%d", ids_count);
+       if (ids_count < 256 && ids_count > 0) {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;
@@ -994,7 +998,7 @@ int bp_history_adaptor_get_timestamp_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count > 0) {
+       if (ids_count < 256 && ids_count > 0) {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;
index 7051203f9e8088c608b10a692bb0fcb3c53a1c4c..5d448765d7e8e8d10622997708a02d0b77d00d38 100755 (executable)
@@ -584,7 +584,7 @@ bp_error_defs bp_common_set_blob(sqlite3 *handle,
                bp_ipc_send_errorcode(sock, BP_ERROR_IO_ERROR);
                return BP_ERROR_IO_ERROR;
        }
-       if (blob_length > 0) {
+       if (blob_length < 256 || blob_length > 0) {
                blob_data =
                        (unsigned char *)calloc(blob_length, sizeof(unsigned char));
                if (blob_data == NULL) {
@@ -648,7 +648,7 @@ bp_error_defs bp_common_set_blob_with_size(sqlite3 *handle,
                bp_ipc_send_errorcode(sock, BP_ERROR_IO_ERROR);
                return BP_ERROR_IO_ERROR;
        }
-       if (blob_length > 0) {
+       if (blob_length < 256 || blob_length > 0) {
                if (bp_ipc_read_custom_type(sock, &width, sizeof(int)) < 0) {
                        TRACE_ERROR("[ERROR][%d] SET_BLOB [IO_ERROR]", id);
                        bp_ipc_send_errorcode(sock, BP_ERROR_IO_ERROR);
@@ -874,7 +874,7 @@ bp_error_defs bp_common_set_blob_shm(sqlite3 *handle,
                bp_ipc_send_errorcode(sock, BP_ERROR_IO_ERROR);
                return BP_ERROR_IO_ERROR;
        }
-       if (blob_length > 0) {
+       if (blob_length < 256 || blob_length > 0) {
 
                unsigned char *blob_buffer = NULL;
                unsigned char *blob_data = NULL;
index 928f225ad671b96d28d5ad73247bf1fba028047b..005b80551ee32bfa6351aacd4a1fd21685fd950f 100755 (executable)
@@ -93,7 +93,11 @@ static int __browser_adaptor_connect(int callback)
        }
        g_bp_command.cmd = BP_CMD_NONE;
        g_bp_command.id = -1;
-       g_bp_command.cid = g_adaptorinfo->cid;
+       if(g_adaptorinfo != NULL) {
+           g_bp_command.cid = g_adaptorinfo->cid;
+       } else {
+           g_bp_command.cid = 0;
+       }
        if (callback == 1 && g_adaptor_event_thread_pid <= 0) {
                // create thread here ( getting event_socket )
                if (pthread_create(&g_adaptor_event_thread_pid, NULL,
@@ -1111,7 +1115,7 @@ int bp_tab_adaptor_get_duplicated_ids_p
        // int count.
        int ids_count = bp_adaptor_ipc_read_int(sock);
        TRACE_DEBUG("response ids count:%d", ids_count);
-       if (ids_count > 0) {
+       if (ids_count < 256 && ids_count > 0) {
                int *idlist = (int *)calloc(ids_count, sizeof(int));
                if (idlist == NULL) {
                        errorcode = BP_ERROR_OUT_OF_MEMORY;