Skip to content
Snippets Groups Projects
Commit d89a4363 authored by alexander.lysikov's avatar alexander.lysikov
Browse files

fixed dap_chain_str_to_hash_fast()

parent 058cfbd3
No related branches found
No related tags found
1 merge request!2Master
...@@ -87,10 +87,10 @@ int dap_chain_str_to_hash_fast( const char * a_hash_str, dap_chain_hash_fast_t * ...@@ -87,10 +87,10 @@ int dap_chain_str_to_hash_fast( const char * a_hash_str, dap_chain_hash_fast_t *
{ {
const size_t c_hash_str_size = sizeof(*a_hash) * 2 + 1 /*trailing zero*/+ 2 /* heading 0x */; const size_t c_hash_str_size = sizeof(*a_hash) * 2 + 1 /*trailing zero*/+ 2 /* heading 0x */;
size_t l_hash_str_len = strlen( a_hash_str); size_t l_hash_str_len = strlen( a_hash_str);
if ( l_hash_str_len == c_hash_str_size ){ if ( l_hash_str_len + 1 == c_hash_str_size ){
for (size_t l_offset = 2; l_offset < c_hash_str_size ; l_offset+=2 ){ for (size_t l_offset = 2; l_offset < l_hash_str_len; l_offset+=2 ){
if ( ( sscanf(a_hash_str+l_offset,"%02hhx",a_hash->raw+l_offset-2) != 1) || if ( ( sscanf(a_hash_str+l_offset,"%02hhx",a_hash->raw+l_offset/2-1) != 1) ||
( sscanf(a_hash_str+l_offset,"%02hhX",a_hash->raw+l_offset-2) != 1) ( sscanf(a_hash_str+l_offset,"%02hhX",a_hash->raw+l_offset/2-1) != 1)
) )
return -10* ((int) l_offset); // Wrong char return -10* ((int) l_offset); // Wrong char
} }
......
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