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

[*] Fixes

parent 741249af
No related branches found
No related tags found
3 merge requests!251Master,!250Master,!187Release 2.5 version
Pipeline #4720 passed with stage
in 10 seconds
......@@ -51,10 +51,10 @@ typedef struct dap_chain_atom_iter{
} dap_chain_atom_iter_t;
typedef enum dap_chain_atom_verify_res{
ATOM_ACCEPT,
ATOM_PASS,
ATOM_REJECT,
ATOM_MOVE_TO_THRESHOLD
ATOM_ACCEPT=0,
ATOM_PASS=1,
ATOM_REJECT=2,
ATOM_MOVE_TO_THRESHOLD=3
} dap_chain_atom_verify_res_t;
typedef dap_chain_t* (*dap_chain_callback_new_t)(void);
......
......@@ -349,8 +349,9 @@ static int s_callback_event_verify(dap_chain_cs_dag_t * a_dag, dap_chain_cs_dag_
{
dap_chain_cs_dag_poa_pvt_t * l_poa_pvt = PVT ( DAP_CHAIN_CS_DAG_POA( a_dag ) );
size_t l_offset_from_beginning = dap_chain_cs_dag_event_calc_size_excl_signs(a_dag_event,a_dag_event_size);
if( l_offset_from_beginning > a_dag_event_size){
log_it(L_WARNING,"Incorrect size with event %p", a_dag_event);
if( l_offset_from_beginning >= a_dag_event_size){
log_it(L_WARNING,"Incorrect size with event %p: caled size excl signs %zd is bigger or equal then event size %zd",
a_dag_event, l_offset_from_beginning, a_dag_event_size);
return -7; // Incorrest size
}
if ( a_dag_event->header.signs_count >= l_poa_pvt->auth_certs_count_verify ){
......
......@@ -287,7 +287,7 @@ static int s_dap_chain_add_atom_to_events_table(dap_chain_cs_dag_t * a_dag, dap_
if(res == 0){
char l_buf_hash[128];
dap_chain_hash_fast_to_str(&a_event_item->hash,l_buf_hash,sizeof(l_buf_hash)-1);
log_it(L_DEBUG,"Dag event %s checked, add it to ledger", a_event_item->hash);
log_it(L_DEBUG,"Dag event %s checked, add it to ledger", l_buf_hash);
res = s_dap_chain_add_atom_to_ledger(a_dag, a_ledger, a_event_item);
HASH_ADD(hh, PVT(a_dag)->events,hash,sizeof (a_event_item->hash), a_event_item);
......@@ -354,7 +354,7 @@ static dap_chain_atom_verify_res_t s_chain_callback_atom_add(dap_chain_t * a_cha
// verify hashes and consensus
if(ret == ATOM_ACCEPT){
ret = s_chain_callback_atom_verify (a_chain, a_atom, a_atom_size);
log_it(L_DEBUG, "Accepted atom %p", a_atom);
log_it(L_DEBUG, "Verified atom %p: code %d", a_atom, ret);
}
if( ret == ATOM_MOVE_TO_THRESHOLD){
......@@ -587,8 +587,10 @@ static dap_chain_atom_verify_res_t s_chain_callback_atom_verify(dap_chain_t * a_
dap_chain_cs_dag_event_t * l_event = (dap_chain_cs_dag_event_t *) a_atom;
dap_chain_atom_verify_res_t res = ATOM_ACCEPT;
if(sizeof (l_event->header)<= a_atom_size)
if(sizeof (l_event->header) >= a_atom_size){
log_it(L_WARNING,"Size of atom is %zd that is equel or less then header %zd",a_atom_size,sizeof (l_event->header));
return ATOM_REJECT;
}
// genesis or seed mode
if (l_event->header.hash_count == 0){
if(s_seed_mode && !PVT(l_dag)->events)
......
......@@ -103,7 +103,7 @@ static inline size_t dap_chain_cs_dag_event_calc_size(dap_chain_cs_dag_event_t *
*/
static inline ssize_t dap_chain_cs_dag_event_calc_size_excl_signs(dap_chain_cs_dag_event_t * a_event,size_t a_event_size)
{
if (a_event_size> sizeof (a_event->header))
if (a_event_size< sizeof (a_event->header))
return -1;
size_t l_hashes_size = a_event->header.hash_count*sizeof(dap_chain_hash_fast_t);
dap_chain_datum_t * l_datum = (dap_chain_datum_t*) (a_event->hashes_n_datum_n_signs + l_hashes_size);
......
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