Skip to content
Snippets Groups Projects
Commit 2f7d3b82 authored by Dmitriy A. Gerasimov's avatar Dmitriy A. Gerasimov
Browse files

[+] Additional check for input data

parent efb9dee5
No related branches found
No related tags found
2 merge requests!251Master,!250Master
Pipeline #5869 passed with stage
in 13 seconds
...@@ -2,7 +2,7 @@ project(cellframe-sdk C) ...@@ -2,7 +2,7 @@ project(cellframe-sdk C)
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD 11)
set(CELLFRAME_SDK_NATIVE_VERSION "2.6-18") set(CELLFRAME_SDK_NATIVE_VERSION "2.6-19")
add_definitions ("-DCELLFRAME_SDK_VERSION=\"${CELLFRAME_SDK_NATIVE_VERSION}\"") add_definitions ("-DCELLFRAME_SDK_VERSION=\"${CELLFRAME_SDK_NATIVE_VERSION}\"")
set(DAPSDK_MODULES "") set(DAPSDK_MODULES "")
......
...@@ -226,61 +226,72 @@ bool s_chain_pkt_callback(dap_proc_thread_t *a_thread, void *a_arg) ...@@ -226,61 +226,72 @@ bool s_chain_pkt_callback(dap_proc_thread_t *a_thread, void *a_arg)
dap_chain_pkt_copy_t *l_pkt_copy = (dap_chain_pkt_copy_t *)l_pkt_copy_list->data; dap_chain_pkt_copy_t *l_pkt_copy = (dap_chain_pkt_copy_t *)l_pkt_copy_list->data;
dap_chain_atom_ptr_t l_atom_copy = (dap_chain_atom_ptr_t)l_pkt_copy->pkt_data; dap_chain_atom_ptr_t l_atom_copy = (dap_chain_atom_ptr_t)l_pkt_copy->pkt_data;
uint64_t l_atom_copy_size = l_pkt_copy->pkt_data_size; uint64_t l_atom_copy_size = l_pkt_copy->pkt_data_size;
dap_hash_fast(l_atom_copy, l_atom_copy_size, &l_atom_hash); if ( l_atom_copy_size && l_pkt_copy && l_atom_copy ){
dap_chain_atom_iter_t *l_atom_iter = l_chain->callback_atom_iter_create(l_chain); dap_hash_fast(l_atom_copy, l_atom_copy_size, &l_atom_hash);
size_t l_atom_size =0; dap_chain_atom_iter_t *l_atom_iter = l_chain->callback_atom_iter_create(l_chain);
if ( l_chain->callback_atom_find_by_hash(l_atom_iter, &l_atom_hash, &l_atom_size) == NULL ) { size_t l_atom_size =0;
dap_chain_atom_verify_res_t l_atom_add_res = l_chain->callback_atom_add(l_chain, l_atom_copy, l_atom_copy_size); if ( l_chain->callback_atom_find_by_hash(l_atom_iter, &l_atom_hash, &l_atom_size) == NULL ) {
if (l_atom_add_res == ATOM_ACCEPT && dap_chain_has_file_store(l_chain)) { dap_chain_atom_verify_res_t l_atom_add_res = l_chain->callback_atom_add(l_chain, l_atom_copy, l_atom_copy_size);
// append to file if (l_atom_add_res == ATOM_ACCEPT && dap_chain_has_file_store(l_chain)) {
dap_chain_cell_t *l_cell = dap_chain_cell_create_fill(l_chain, l_ch_chain->request_cell_id); // append to file
int l_res; dap_chain_cell_t *l_cell = dap_chain_cell_create_fill(l_chain, l_ch_chain->request_cell_id);
if (l_cell) { int l_res;
// add one atom only if (l_cell) {
l_res = dap_chain_cell_file_append(l_cell, l_atom_copy, l_atom_copy_size); // add one atom only
// rewrite all file l_res = dap_chain_cell_file_append(l_cell, l_atom_copy, l_atom_copy_size);
//l_res = dap_chain_cell_file_update(l_cell); // rewrite all file
if(l_res < 0) { //l_res = dap_chain_cell_file_update(l_cell);
log_it(L_ERROR, "Can't save event 0x%x to the file '%s'", l_atom_hash, if(l_res < 0) {
l_cell ? l_cell->file_storage_path : "[null]"); log_it(L_ERROR, "Can't save event 0x%x to the file '%s'", l_atom_hash,
} l_cell ? l_cell->file_storage_path : "[null]");
// add all atoms from treshold }
if (l_chain->callback_atom_add_from_treshold){ // add all atoms from treshold
dap_chain_atom_ptr_t l_atom_treshold; if (l_chain->callback_atom_add_from_treshold){
do{ dap_chain_atom_ptr_t l_atom_treshold;
size_t l_atom_treshold_size; do{
// add into ledger size_t l_atom_treshold_size;
log_it(L_DEBUG, "Try to add atom from treshold"); // add into ledger
l_atom_treshold = l_chain->callback_atom_add_from_treshold(l_chain, &l_atom_treshold_size); log_it(L_DEBUG, "Try to add atom from treshold");
// add into file l_atom_treshold = l_chain->callback_atom_add_from_treshold(l_chain, &l_atom_treshold_size);
if(l_atom_treshold) { // add into file
l_res = dap_chain_cell_file_append(l_cell, l_atom_treshold, l_atom_treshold_size); if(l_atom_treshold) {
log_it(L_DEBUG, "Added atom from treshold"); l_res = dap_chain_cell_file_append(l_cell, l_atom_treshold, l_atom_treshold_size);
if(l_res < 0) { log_it(L_DEBUG, "Added atom from treshold");
log_it(L_ERROR, "Can't save event 0x%x from treshold to the file '%s'", if(l_res < 0) {
l_atom_treshold, l_cell ? l_cell->file_storage_path : "[null]"); log_it(L_ERROR, "Can't save event 0x%x from treshold to the file '%s'",
l_atom_treshold, l_cell ? l_cell->file_storage_path : "[null]");
}
} }
} }
while(l_atom_treshold);
} }
while(l_atom_treshold);
}
// delete cell and close file // delete cell and close file
dap_chain_cell_delete(l_cell); dap_chain_cell_delete(l_cell);
} }
else{ else{
log_it(L_ERROR, "Can't get cell for cell_id 0x%x for save event to file", l_ch_chain->request_cell_id); log_it(L_ERROR, "Can't get cell for cell_id 0x%x for save event to file", l_ch_chain->request_cell_id);
}
} }
} if(l_atom_add_res == ATOM_PASS)
if(l_atom_add_res == ATOM_PASS) DAP_DELETE(l_atom_copy);
} else {
DAP_DELETE(l_atom_copy); DAP_DELETE(l_atom_copy);
} else { }
DAP_DELETE(l_atom_copy); l_chain->callback_atom_iter_delete(l_atom_iter);
}else{
if (!l_pkt_copy)
log_it(L_WARNING, "packet copy is NULL");
if (!l_pkt_copy_list)
log_it(L_WARNING, "packet copy list is NULL");
if (l_atom_copy_size)
log_it(L_WARNING, "Atom copy size is zero");
} }
l_chain->callback_atom_iter_delete(l_atom_iter); if (l_pkt_copy)
DAP_DELETE(l_pkt_copy); DAP_DELETE(l_pkt_copy);
DAP_DELETE(l_pkt_copy_list); if (l_pkt_copy_list)
DAP_DELETE(l_pkt_copy_list);
}else }else
log_it(L_WARNING, "In proc thread got CHAINS stream ch packet with zero data"); log_it(L_WARNING, "In proc thread got CHAINS stream ch packet with zero data");
dap_events_socket_assign_on_worker_mt(l_ch->stream->esocket, l_ch->stream_worker->worker); dap_events_socket_assign_on_worker_mt(l_ch->stream->esocket, l_ch->stream_worker->worker);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment