From a3d33168deb68ca98ada5d4e3a44f318c92286b5 Mon Sep 17 00:00:00 2001 From: HyeKyoung Hwang Date: Mon, 13 Mar 2017 17:43:37 +0900 Subject: [PATCH] Fix the Crash for increase max ids limit [Problem] Cloud pdm sync server is crashing due to less limit [Cause & Measure] Increase the limit and do proper check [Checking Method] Keep a lot of tabs to sync, launch cloud pdm syn Change-Id: I0f272b9786229460168d82431692ba4f16a85f41 Signed-off-by: HyeKyoung Hwang --- bookmark-adaptor/bookmark-adaptor.c | 6 +++--- bookmark-csc-adaptor/bookmark-csc-adaptor.c | 4 ++-- common-adaptor/common-adaptor.c | 8 ++++++-- common-adaptor/include/common-adaptor.h | 2 ++ history-adaptor/history-adaptor.c | 4 ++-- tab-adaptor/tab-adaptor.c | 2 +- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/bookmark-adaptor/bookmark-adaptor.c b/bookmark-adaptor/bookmark-adaptor.c index da0144b..e642d14 100755 --- a/bookmark-adaptor/bookmark-adaptor.c +++ b/bookmark-adaptor/bookmark-adaptor.c @@ -1011,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 < 256 && ids_count > 0) { + if (ids_count < BP_MAX_IDS_COUNT && ids_count > 0) { int *idlist = (int *)calloc(ids_count, sizeof(int)); if (idlist == NULL) { errorcode = BP_ERROR_OUT_OF_MEMORY; @@ -1156,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 < 256 && ids_count > 0) { + if (ids_count < BP_MAX_IDS_COUNT && ids_count > 0) { int *idlist = (int *)calloc(ids_count, sizeof(int)); if (idlist == NULL) { errorcode = BP_ERROR_OUT_OF_MEMORY; @@ -1261,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 < 256 && ids_count > 0) { + if (ids_count < BP_MAX_IDS_COUNT && 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 6a00629..0f1b5c1 100755 --- a/bookmark-csc-adaptor/bookmark-csc-adaptor.c +++ b/bookmark-csc-adaptor/bookmark-csc-adaptor.c @@ -161,7 +161,7 @@ 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 >= 256 || ids_count <= 0) { + if(ids_count >= BP_MAX_IDS_COUNT || ids_count <= 0) { pthread_mutex_unlock(&g_adaptor_mutex); return -1; } else { @@ -263,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 < 256 && ids_count > 0) { + if (ids_count < BP_MAX_IDS_COUNT && ids_count > 0) { int *idlist = (int *)calloc(ids_count, sizeof(int)); if (idlist == NULL) { errorcode = BP_ERROR_OUT_OF_MEMORY; diff --git a/common-adaptor/common-adaptor.c b/common-adaptor/common-adaptor.c index 8a3a365..95539d5 100755 --- a/common-adaptor/common-adaptor.c +++ b/common-adaptor/common-adaptor.c @@ -276,7 +276,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 < 256 && ids_count > 0) { + if (ids_count < BP_MAX_IDS_COUNT && ids_count > 0) { idlist = (int *)calloc(ids_count, sizeof(int)); if (idlist == NULL) { TRACE_ERROR("[CRITICAL] allocation"); @@ -293,8 +293,12 @@ int bp_common_adaptor_get_ids_p(const int sock, bp_command_fmt *cmd, return -1; } *ids = idlist; + return ids_count; } - return ids_count; + else if (ids_count >= BP_MAX_IDS_COUNT) { + TRACE_DEBUG("Count exceeded [%d]", ids_count); + return -1; + } } int bp_common_adaptor_get_string(const int sock, bp_command_fmt *cmd, diff --git a/common-adaptor/include/common-adaptor.h b/common-adaptor/include/common-adaptor.h index 93178dc..f574eba 100755 --- a/common-adaptor/include/common-adaptor.h +++ b/common-adaptor/include/common-adaptor.h @@ -105,6 +105,8 @@ int bp_common_adaptor_clear_read_buffer(int sock, size_t length); }\ } while(0) +#define BP_MAX_IDS_COUNT 512 + #define BP_CHECK_IPC_SOCK (g_adaptorinfo == NULL ? -1 : g_adaptorinfo->cmd_socket) #define BP_PRINT_ERROR(id, errorcode) bp_common_print_errorcode(__FUNCTION__, __LINE__, id, errorcode) diff --git a/history-adaptor/history-adaptor.c b/history-adaptor/history-adaptor.c index b975335..c184cbf 100755 --- a/history-adaptor/history-adaptor.c +++ b/history-adaptor/history-adaptor.c @@ -867,7 +867,7 @@ static int __bp_history_adaptor_get_cond_ids_p // int count. int ids_count = bp_adaptor_ipc_read_int(sock); TRACE_ERROR("response ids count:%d", ids_count); - if (ids_count < 256 && ids_count > 0) { + if (ids_count < BP_MAX_IDS_COUNT && ids_count > 0) { int *idlist = (int *)calloc(ids_count, sizeof(int)); if (idlist == NULL) { errorcode = BP_ERROR_OUT_OF_MEMORY; @@ -998,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 < 256 && ids_count > 0) { + if (ids_count < BP_MAX_IDS_COUNT && ids_count > 0) { int *idlist = (int *)calloc(ids_count, sizeof(int)); if (idlist == NULL) { errorcode = BP_ERROR_OUT_OF_MEMORY; diff --git a/tab-adaptor/tab-adaptor.c b/tab-adaptor/tab-adaptor.c index 005b805..386b18f 100755 --- a/tab-adaptor/tab-adaptor.c +++ b/tab-adaptor/tab-adaptor.c @@ -1115,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 < 256 && ids_count > 0) { + if (ids_count < BP_MAX_IDS_COUNT&& ids_count > 0) { int *idlist = (int *)calloc(ids_count, sizeof(int)); if (idlist == NULL) { errorcode = BP_ERROR_OUT_OF_MEMORY; -- 2.34.1