}
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,
// 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;
// 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;
// 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;
BP_CSC_CHECK_PROVIDER_STATUS;
+ pthread_mutex_lock(&g_adaptor_mutex);
int sock = BP_CHECK_IPC_SOCK;
bp_command_fmt *cmd = &g_bp_command;
// 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;
BP_CSC_CHECK_PROVIDER_STATUS;
+ pthread_mutex_lock(&g_adaptor_mutex);
int sock = BP_CHECK_IPC_SOCK;
bp_command_fmt *cmd = &g_bp_command;
// 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;
}
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;
// 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");
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) {
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,
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
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);\
}
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,
}
// 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;
// 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;
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) {
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);
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;
}
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,
// 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;