Skip to content
Snippets Groups Projects
Commit 7096dd73 authored by Roman Khlopkov's avatar Roman Khlopkov 🔜
Browse files

Merge branch 'bugfix-8567' into 'release-5.2'

Bugfix 8567

See merge request !1076
parents 9182325b 36cd548c
No related branches found
No related tags found
1 merge request!1076Bugfix 8567
Pipeline #25929 failed with stage
in 5 minutes and 58 seconds
Subproject commit d33c3b2e4cc52937947bc428f377b789fef12f15
Subproject commit a5e0725cef9ddc54c059fd948db93d9ffd52949c
......@@ -33,6 +33,7 @@
#include "dap_sign.h"
#include "dap_hash.h"
#include <json-c/json.h>
#include "dap_strfuncs.h"
#define DAP_CHAIN_ADDR_VERSION_CURRENT 1
......@@ -86,6 +87,24 @@ typedef union dap_chain_node_addr {
#define NODE_ADDR_FPS_ARGS_S(a) &a.words[3],&a.words[2],&a.words[1],&a.words[0]
#endif
DAP_STATIC_INLINE bool dap_chain_node_addr_str_check(const char *a_addr_str) {
size_t l_str_len = dap_strlen(a_addr_str);
if (l_str_len == 22) {
for (int n =0; n < 22; n+= 6) {
if (!dap_is_xdigit(a_addr_str[n]) || !dap_is_xdigit(a_addr_str[n + 1]) ||
!dap_is_xdigit(a_addr_str[n + 2]) || !dap_is_xdigit(a_addr_str[n + 3])) {
return false;
}
}
for (int n = 4; n < 18; n += 6) {
if (a_addr_str[n] != ':' || a_addr_str[n + 1] != ':')
return false;
}
return true;
}
return false;
}
DAP_STATIC_INLINE int dap_chain_node_addr_from_str(dap_chain_node_addr_t *a_addr, const char *a_addr_str)
{
if (sscanf(a_addr_str, NODE_ADDR_FP_STR, NODE_ADDR_FPS_ARGS(a_addr)) == 4)
......
......@@ -497,9 +497,9 @@ static int s_cli_net_srv( int argc, char **argv, char **a_str_reply)
l_expires = (dap_time_t ) atoll( l_expires_str);
l_srv_uid.uint64 = (uint64_t) atoll( l_srv_uid_str);
if (l_node_addr_str){
if (dap_chain_node_addr_from_str( &l_node_addr, l_node_addr_str ) == 0 )
log_it( L_DEBUG, "node addr " NODE_ADDR_FP_STR, NODE_ADDR_FP_ARGS_S(l_node_addr) );
else {
if (dap_chain_node_addr_str_check(l_node_addr_str)) {
dap_chain_node_addr_from_str( &l_node_addr, l_node_addr_str );
} else {
log_it(L_ERROR, "Can't parse \"%s\" as node addr", l_node_addr_str);
dap_cli_server_cmd_set_reply_text(a_str_reply, "The order has not been created. "
"Failed to convert string representation of '%s' "
......
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