mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-26 01:03:15 +03:00
CVE-2023-6004: torture_misc: Add test for ssh_is_ipaddr
Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
committed by
Andreas Schneider
parent
7b697d711e
commit
92e35c291c
@@ -1051,6 +1051,31 @@ static void torture_ssh_check_hostname_syntax(void **state)
|
||||
assert_int_equal(rc, SSH_ERROR);
|
||||
}
|
||||
|
||||
static void torture_ssh_is_ipaddr(void **state) {
|
||||
int rc;
|
||||
(void)state;
|
||||
|
||||
rc = ssh_is_ipaddr("201.255.3.69");
|
||||
assert_int_equal(rc, 1);
|
||||
rc = ssh_is_ipaddr("::1");
|
||||
assert_int_equal(rc, 1);
|
||||
rc = ssh_is_ipaddr("2001:0db8:85a3:0000:0000:8a2e:0370:7334");
|
||||
assert_int_equal(rc, 1);
|
||||
|
||||
rc = ssh_is_ipaddr("..");
|
||||
assert_int_equal(rc, 0);
|
||||
rc = ssh_is_ipaddr(":::");
|
||||
assert_int_equal(rc, 0);
|
||||
rc = ssh_is_ipaddr("1.1.1.1.1");
|
||||
assert_int_equal(rc, 0);
|
||||
rc = ssh_is_ipaddr("1.1");
|
||||
assert_int_equal(rc, 0);
|
||||
rc = ssh_is_ipaddr("caesar");
|
||||
assert_int_equal(rc, 0);
|
||||
rc = ssh_is_ipaddr("::xa:1");
|
||||
assert_int_equal(rc, 0);
|
||||
}
|
||||
|
||||
int torture_run_tests(void) {
|
||||
int rc;
|
||||
struct CMUnitTest tests[] = {
|
||||
@@ -1078,6 +1103,7 @@ int torture_run_tests(void) {
|
||||
cmocka_unit_test(torture_ssh_readn),
|
||||
cmocka_unit_test(torture_ssh_writen),
|
||||
cmocka_unit_test(torture_ssh_check_hostname_syntax),
|
||||
cmocka_unit_test(torture_ssh_is_ipaddr),
|
||||
};
|
||||
|
||||
ssh_init();
|
||||
|
||||
Reference in New Issue
Block a user