mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-10-28 16:57:24 +03:00
fuzz: Read environment variable to provide verbose logging
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Pavol Žáčik <pzacik@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/840>
This commit is contained in:
@@ -48,6 +48,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
ssh_bind bind = NULL;
|
||||
char *input = NULL;
|
||||
const char *env = NULL;
|
||||
|
||||
input = (char *)malloc(size + 1);
|
||||
if (!input) {
|
||||
@@ -63,6 +64,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
goto out;
|
||||
}
|
||||
|
||||
env = getenv("LIBSSH_VERBOSITY");
|
||||
if (env != NULL && strlen(env) > 0) {
|
||||
ssh_bind_options_set(bind, SSH_BIND_OPTIONS_LOG_VERBOSITY_STR, env);
|
||||
}
|
||||
ssh_bind_config_parse_string(bind, input);
|
||||
|
||||
ssh_bind_free(bind);
|
||||
|
||||
@@ -47,6 +47,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
ssh_session session = NULL;
|
||||
char *input = NULL;
|
||||
const char *env = NULL;
|
||||
|
||||
input = (char *)malloc(size+1);
|
||||
if (!input) {
|
||||
@@ -62,6 +63,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
goto out;
|
||||
}
|
||||
|
||||
env = getenv("LIBSSH_VERBOSITY");
|
||||
if (env != NULL && strlen(env) > 0) {
|
||||
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY_STR, env);
|
||||
}
|
||||
/* Make sure we have default options set */
|
||||
ssh_options_set(session, SSH_OPTIONS_SSH_DIR, NULL);
|
||||
ssh_options_set(session, SSH_OPTIONS_HOST, "example.com");
|
||||
|
||||
Reference in New Issue
Block a user