mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 10:40:27 +09:00
CVE-2023-6004: torture_misc: Add tests for ipv6 link-local
Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
cdaec0d627
commit
6a8a18c73e
@@ -17,7 +17,14 @@
|
|||||||
#include "misc.c"
|
#include "misc.c"
|
||||||
#include "error.c"
|
#include "error.c"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <netioapi.h>
|
||||||
|
#else
|
||||||
|
#include <net/if.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TORTURE_TEST_DIR "/usr/local/bin/truc/much/.."
|
#define TORTURE_TEST_DIR "/usr/local/bin/truc/much/.."
|
||||||
|
#define TORTURE_IPV6_LOCAL_LINK "fe80::98e1:82ff:fe8d:28b3%%%s"
|
||||||
|
|
||||||
const char template[] = "temp_dir_XXXXXX";
|
const char template[] = "temp_dir_XXXXXX";
|
||||||
|
|
||||||
@@ -730,14 +737,27 @@ static void torture_ssh_check_hostname_syntax(void **state)
|
|||||||
|
|
||||||
static void torture_ssh_is_ipaddr(void **state) {
|
static void torture_ssh_is_ipaddr(void **state) {
|
||||||
int rc;
|
int rc;
|
||||||
|
char *interf = malloc(64);
|
||||||
|
char *test_interf = malloc(128);
|
||||||
(void)state;
|
(void)state;
|
||||||
|
|
||||||
|
assert_non_null(interf);
|
||||||
|
assert_non_null(test_interf);
|
||||||
rc = ssh_is_ipaddr("201.255.3.69");
|
rc = ssh_is_ipaddr("201.255.3.69");
|
||||||
assert_int_equal(rc, 1);
|
assert_int_equal(rc, 1);
|
||||||
rc = ssh_is_ipaddr("::1");
|
rc = ssh_is_ipaddr("::1");
|
||||||
assert_int_equal(rc, 1);
|
assert_int_equal(rc, 1);
|
||||||
rc = ssh_is_ipaddr("2001:0db8:85a3:0000:0000:8a2e:0370:7334");
|
rc = ssh_is_ipaddr("2001:0db8:85a3:0000:0000:8a2e:0370:7334");
|
||||||
assert_int_equal(rc, 1);
|
assert_int_equal(rc, 1);
|
||||||
|
if_indextoname(1, interf);
|
||||||
|
assert_non_null(interf);
|
||||||
|
rc = sprintf(test_interf, TORTURE_IPV6_LOCAL_LINK, interf);
|
||||||
|
/* the "%%s" is not written */
|
||||||
|
assert_int_equal(rc, strlen(interf) + strlen(TORTURE_IPV6_LOCAL_LINK) - 3);
|
||||||
|
rc = ssh_is_ipaddr(test_interf);
|
||||||
|
assert_int_equal(rc, 1);
|
||||||
|
free(interf);
|
||||||
|
free(test_interf);
|
||||||
|
|
||||||
rc = ssh_is_ipaddr("..");
|
rc = ssh_is_ipaddr("..");
|
||||||
assert_int_equal(rc, 0);
|
assert_int_equal(rc, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user