From: Lim DoHyung Date: Mon, 19 Sep 2016 04:51:53 +0000 (+0900) Subject: [svace] browser-provider issue fixed. X-Git-Tag: submit/tizen_mobile/20160921.082004^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c4d44b1f69f9c89bf2b1f77502fa64e51a03107;p=platform%2Fframework%2Fweb%2Fbrowser-provider.git [svace] browser-provider issue fixed. Change-Id: I3d9ac29f92db6468d5d1331f7e6a0e6eee801896 Signed-off-by: Lim DoHyung --- diff --git a/bookmark-adaptor/bookmark-adaptor.c b/bookmark-adaptor/bookmark-adaptor.c index 97792ec..da0144b 100755 --- a/bookmark-adaptor/bookmark-adaptor.c +++ b/bookmark-adaptor/bookmark-adaptor.c @@ -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; diff --git a/bookmark-csc-adaptor/bookmark-csc-adaptor.c b/bookmark-csc-adaptor/bookmark-csc-adaptor.c index 1fafa73..6a00629 100755 --- a/bookmark-csc-adaptor/bookmark-csc-adaptor.c +++ b/bookmark-csc-adaptor/bookmark-csc-adaptor.c @@ -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; diff --git a/common-adaptor/common-adaptor.c b/common-adaptor/common-adaptor.c index 05c0262..f213729 100755 --- a/common-adaptor/common-adaptor.c +++ b/common-adaptor/common-adaptor.c @@ -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 diff --git a/common-adaptor/include/common-adaptor.h b/common-adaptor/include/common-adaptor.h index 9eb7134..93178dc 100755 --- a/common-adaptor/include/common-adaptor.h +++ b/common-adaptor/include/common-adaptor.h @@ -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);\ diff --git a/history-adaptor/history-adaptor.c b/history-adaptor/history-adaptor.c index 0f966a0..b975335 100755 --- a/history-adaptor/history-adaptor.c +++ b/history-adaptor/history-adaptor.c @@ -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; diff --git a/provider/browser-provider-requests.c b/provider/browser-provider-requests.c index 7051203..5d44876 100755 --- a/provider/browser-provider-requests.c +++ b/provider/browser-provider-requests.c @@ -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; diff --git a/tab-adaptor/tab-adaptor.c b/tab-adaptor/tab-adaptor.c index 928f225..005b805 100755 --- a/tab-adaptor/tab-adaptor.c +++ b/tab-adaptor/tab-adaptor.c @@ -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;