From 9a70cfa3d226caecbb5f8ddecece7176f6b73333 Mon Sep 17 00:00:00 2001 From: "daniil.frolov" <daniil.frolov@demlabs.net> Date: Wed, 21 Jun 2023 10:15:16 +0000 Subject: [PATCH] features-5458 --- crypto/src/rand/dap_rand.c | 18 ++++++++---------- .../http_server/http_client/dap_http_client.c | 2 +- plugin/src/dap_plugin_command.c | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/crypto/src/rand/dap_rand.c b/crypto/src/rand/dap_rand.c index 3476e2cb4..7b48234bc 100755 --- a/crypto/src/rand/dap_rand.c +++ b/crypto/src/rand/dap_rand.c @@ -92,7 +92,6 @@ int randombytes(void* random_array, unsigned int nbytes) return passed; #else int r, n = (int)nbytes, count = 0; - if (lock == -1) { do { lock = open("/dev/urandom", O_RDONLY); @@ -102,16 +101,15 @@ int randombytes(void* random_array, unsigned int nbytes) } while (lock == -1); } - while (n > 0) { - do { - r = read(lock, random_array+count, n); - if (r == -1) { - delay(0xFFFF); - } - } while (r == -1); - count += r; - n -= r; + for(int i = 0; i < n;){ + r = read(lock, (char*)random_array+i, n); + if (r >= 0){ + i += r; + } else{ + delay(0xFFFF); + } } + #endif return passed; diff --git a/net/server/http_server/http_client/dap_http_client.c b/net/server/http_server/http_client/dap_http_client.c index 005cf56c7..3bc6db008 100644 --- a/net/server/http_server/http_client/dap_http_client.c +++ b/net/server/http_server/http_client/dap_http_client.c @@ -248,7 +248,7 @@ const char ht_ver [] = "HTTP/1."; /* W ** /issues/6099?issue_count=148 HTTP/1.1 -> "/issues/6099" */ l_cp_start = l_cp_end; - for ( ; (*l_cp_start != '/') && l_len; l_cp_start++, l_buf_len--); /* Skip possible anti-DPI whitespaces to '/' */ + for ( ; (*l_cp_start != '/') && l_len && l_buf_len; l_cp_start++, l_buf_len--); /* Skip possible anti-DPI whitespaces to '/' */ l_cp_end = l_cp_start; for ( ; (*l_cp_end != '?') && !isspace(*l_cp_end) && l_buf_len; l_cp_end++, l_buf_len--); /* Run over <path> up to first <space> or '?' */ diff --git a/plugin/src/dap_plugin_command.c b/plugin/src/dap_plugin_command.c index 2f19e5004..f61f188c5 100644 --- a/plugin/src/dap_plugin_command.c +++ b/plugin/src/dap_plugin_command.c @@ -76,7 +76,7 @@ static int s_command_handler(int a_argc, char **a_argv, char **a_str_reply) l_str, "|\t",l_manifest->name, "\t|\t", l_manifest->version, "\t|\t", l_manifest->author, "\t|\n", NULL); } - dap_cli_server_cmd_set_reply_text(a_str_reply, l_str); + dap_cli_server_cmd_set_reply_text(a_str_reply, "%s", l_str); }break; case CMD_SHOW_NAME: if(!l_cmd_arg){ -- GitLab