64 lines
1.9 KiB
Diff
64 lines
1.9 KiB
Diff
From 2c492ee179d5caa2718c5e768bab6e0b2b64a8b0 Mon Sep 17 00:00:00 2001
|
|
From: Norbert Pocs <norbertpocs0@gmail.com>
|
|
Date: Tue, 28 Nov 2023 15:27:31 +0100
|
|
Subject: [PATCH 10/20] 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>
|
|
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
|
|
---
|
|
tests/unittests/torture_misc.c | 20 ++++++++++++++++++++
|
|
1 file changed, 20 insertions(+)
|
|
|
|
diff --git a/tests/unittests/torture_misc.c b/tests/unittests/torture_misc.c
|
|
index b07392ab..77166759 100644
|
|
--- a/tests/unittests/torture_misc.c
|
|
+++ b/tests/unittests/torture_misc.c
|
|
@@ -17,7 +17,14 @@
|
|
#include "torture.h"
|
|
#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_IPV6_LOCAL_LINK "fe80::98e1:82ff:fe8d:28b3%%%s"
|
|
|
|
const char template[] = "temp_dir_XXXXXX";
|
|
|
|
@@ -834,14 +841,27 @@ static void torture_ssh_check_hostname_syntax(void **state)
|
|
|
|
static void torture_ssh_is_ipaddr(void **state) {
|
|
int rc;
|
|
+ char *interf = malloc(64);
|
|
+ char *test_interf = malloc(128);
|
|
(void)state;
|
|
|
|
+ assert_non_null(interf);
|
|
+ assert_non_null(test_interf);
|
|
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);
|
|
+ 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("..");
|
|
assert_int_equal(rc, 0);
|
|
--
|
|
2.33.0
|
|
|