From 163373c9d95ebb0ca7721ea7a85f3fd56244eb9c Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Mon, 15 Dec 2025 11:07:08 +0100 Subject: [PATCH] tests: Reproducer for missing value to LogLevel Signed-off-by: Jakub Jelen Reviewed-by: Andreas Schneider --- tests/unittests/torture_config.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/unittests/torture_config.c b/tests/unittests/torture_config.c index 7cd0f2e2..5984b03f 100644 --- a/tests/unittests/torture_config.c +++ b/tests/unittests/torture_config.c @@ -53,6 +53,7 @@ extern LIBSSH_THREAD int ssh_log_level; #define LIBSSH_TEST_NONEWLINEONELINE "libssh_test_NoNewLineOneline.tmp" #define LIBSSH_TEST_RECURSIVE_INCLUDE "libssh_test_recursive_include.tmp" #define LIBSSH_TESTCONFIG_MATCH_COMPLEX "libssh_test_match_complex.tmp" +#define LIBSSH_TESTCONFIG_LOGLEVEL_MISSING "libssh_test_loglevel_missing.tmp" #define LIBSSH_TESTCONFIG_STRING1 \ "User "USERNAME"\nInclude "LIBSSH_TESTCONFIG2"\n\n" @@ -244,6 +245,8 @@ extern LIBSSH_THREAD int ssh_log_level; "\tForwardAgent yes\n" \ "\tHostName complex-match\n" +#define LIBSSH_TESTCONFIG_LOGLEVEL_MISSING_STRING "LogLevel\n" + /** * @brief helper function loading configuration from either file or string */ @@ -294,6 +297,7 @@ static int setup_config_files(void **state) unlink(LIBSSH_TEST_NONEWLINEEND); unlink(LIBSSH_TEST_NONEWLINEONELINE); unlink(LIBSSH_TESTCONFIG_MATCH_COMPLEX); + unlink(LIBSSH_TESTCONFIG_LOGLEVEL_MISSING); torture_write_file(LIBSSH_TESTCONFIG1, LIBSSH_TESTCONFIG_STRING1); @@ -362,6 +366,8 @@ static int setup_config_files(void **state) /* Match complex combinations */ torture_write_file(LIBSSH_TESTCONFIG_MATCH_COMPLEX, LIBSSH_TESTCONFIG_MATCH_COMPLEX_STRING); + torture_write_file(LIBSSH_TESTCONFIG_LOGLEVEL_MISSING, + LIBSSH_TESTCONFIG_LOGLEVEL_MISSING_STRING); return 0; } @@ -391,6 +397,7 @@ static int teardown_config_files(void **state) unlink(LIBSSH_TEST_NONEWLINEEND); unlink(LIBSSH_TEST_NONEWLINEONELINE); unlink(LIBSSH_TESTCONFIG_MATCH_COMPLEX); + unlink(LIBSSH_TESTCONFIG_LOGLEVEL_MISSING); return 0; } @@ -2619,6 +2626,17 @@ static void torture_config_match_complex(void **state) ssh_string_free_char(v); } +/* Missing value to LogLevel configuration option + */ +static void torture_config_loglevel_missing_value(void **state) +{ + ssh_session session = *state; + + ssh_options_set(session, SSH_OPTIONS_HOST, "Bar"); + + _parse_config(session, LIBSSH_TESTCONFIG_LOGLEVEL_MISSING, NULL, SSH_OK); +} + int torture_run_tests(void) { int rc; @@ -2761,6 +2779,9 @@ int torture_run_tests(void) cmocka_unit_test_setup_teardown(torture_config_match_complex, setup, teardown), + cmocka_unit_test_setup_teardown(torture_config_loglevel_missing_value, + setup, + teardown), }; ssh_init();