Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cellframe-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
16
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
cellframe-sdk
Commits
35bb36dc
Commit
35bb36dc
authored
4 years ago
by
Aleksei Voronin
Browse files
Options
Downloads
Patches
Plain Diff
[*] cli fields are now checked against forbidden symbols
parent
f0bb7842
No related branches found
No related tags found
Loading
Pipeline
#4539
passed with stage
in 13 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/app-cli/dap_app_cli_net.c
+30
-1
30 additions, 1 deletion
modules/app-cli/dap_app_cli_net.c
with
30 additions
and
1 deletion
modules/app-cli/dap_app_cli_net.c
+
30
−
1
View file @
35bb36dc
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#include
<sys/types.h>
#include
<sys/types.h>
#include
<assert.h>
#include
<assert.h>
#include
<errno.h>
#include
<errno.h>
#include
<stdbool.h>
#ifdef _WIN32
#ifdef _WIN32
#include
<winsock2.h>
#include
<winsock2.h>
...
@@ -47,6 +48,7 @@
...
@@ -47,6 +48,7 @@
#include
"dap_chain_node_cli.h"
// for UNIX_SOCKET_FILE
#include
"dap_chain_node_cli.h"
// for UNIX_SOCKET_FILE
#include
"dap_app_cli.h"
#include
"dap_app_cli.h"
#include
"dap_app_cli_net.h"
#include
"dap_app_cli_net.h"
#include
"dap_enc_base64.h"
static
int
s_status
;
static
int
s_status
;
...
@@ -155,6 +157,27 @@ dap_app_cli_connect_param_t* dap_app_cli_connect(const char *a_socket_path)
...
@@ -155,6 +157,27 @@ dap_app_cli_connect_param_t* dap_app_cli_connect(const char *a_socket_path)
return
l_ret
;
return
l_ret
;
}
}
/* if cli command argument contains one of the following symbol
argument is going to be encoded to base64 */
static
const
char
*
s_dap_app_cli_forbidden_symbols
[]
=
{
"
\r\n
"
,
";"
,
""
};
bool
s_dap_app_cli_cmd_contains_forbidden_symbol
(
const
char
*
a_cmd_param
){
for
(
int
i
=
0
;
s_dap_app_cli_forbidden_symbols
[
i
][
0
]
!=
'\0'
;
i
++
){
if
(
strstr
(
a_cmd_param
,
s_dap_app_cli_forbidden_symbols
[
i
]))
return
true
;
}
return
false
;
}
char
*
s_dap_app_cli_strdup_to_base64
(
const
char
*
a_cmd_param
){
size_t
l_cmd_param_len
=
strlen
(
a_cmd_param
);
size_t
l_cmd_param_base64_len
=
DAP_ENC_BASE64_ENCODE_SIZE
(
l_cmd_param_len
)
+
1
;
char
*
l_cmd_param_base64
=
DAP_NEW_SIZE
(
char
,
l_cmd_param_base64_len
);
size_t
l_cmd_param_base64_len_res
=
dap_enc_base64_encode
(
a_cmd_param
,
l_cmd_param_len
,
l_cmd_param_base64
,
DAP_ENC_DATA_TYPE_B64
);
l_cmd_param_base64
[
l_cmd_param_base64_len_res
]
=
'\0'
;
return
l_cmd_param_base64
;
}
/**
/**
* Send request to kelvin-node
* Send request to kelvin-node
*
*
...
@@ -174,7 +197,13 @@ int dap_app_cli_post_command( dap_app_cli_connect_param_t *a_socket, dap_app_cli
...
@@ -174,7 +197,13 @@ int dap_app_cli_post_command( dap_app_cli_connect_param_t *a_socket, dap_app_cli
for
(
int
i
=
0
;
i
<
a_cmd
->
cmd_param_count
;
i
++
)
{
for
(
int
i
=
0
;
i
<
a_cmd
->
cmd_param_count
;
i
++
)
{
if
(
a_cmd
->
cmd_param
[
i
])
{
if
(
a_cmd
->
cmd_param
[
i
])
{
dap_string_append
(
l_cmd_data
,
"
\r\n
"
);
dap_string_append
(
l_cmd_data
,
"
\r\n
"
);
dap_string_append
(
l_cmd_data
,
a_cmd
->
cmd_param
[
i
]);
if
(
s_dap_app_cli_cmd_contains_forbidden_symbol
(
a_cmd
->
cmd_param
[
i
])){
char
*
l_cmd_param_base64
=
s_dap_app_cli_strdup_to_base64
(
a_cmd
->
cmd_param
[
i
]);
dap_string_append
(
l_cmd_data
,
l_cmd_param_base64
);
DAP_DELETE
(
l_cmd_param_base64
);
}
else
{
dap_string_append
(
l_cmd_data
,
a_cmd
->
cmd_param
[
i
]);
}
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment