From 314908f451e6b2d4ccf6212ad246fa4619c721d3 Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Wed, 4 Jul 2018 13:51:45 +0000 Subject: upstream: deal with API rename: match_filter_list() => match_filter_blacklist() OpenBSD-Regress-ID: 2da342be913efeb51806351af906fab01ba4367f --- regress/unittests/match/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'regress/unittests') diff --git a/regress/unittests/match/tests.c b/regress/unittests/match/tests.c index e1593367b..3d9af55f2 100644 --- a/regress/unittests/match/tests.c +++ b/regress/unittests/match/tests.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tests.c,v 1.4 2017/02/03 23:01:42 djm Exp $ */ +/* $OpenBSD: tests.c,v 1.5 2018/07/04 13:51:45 djm Exp $ */ /* * Regress test for matching functions * @@ -105,7 +105,7 @@ tests(void) #define CHECK_FILTER(string,filter,expected) \ do { \ - char *result = match_filter_list((string), (filter)); \ + char *result = match_filter_blacklist((string), (filter)); \ ASSERT_STRING_EQ(result, expected); \ free(result); \ } while (0) -- cgit v1.2.3 From dbab02f9208d9baa134cec1d007054ec82b96ca9 Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Fri, 13 Jul 2018 02:13:19 +0000 Subject: upstream: fix leaks in unit test; with this, all unit tests are leak free (as far as valgrind can spot anyway) OpenBSD-Regress-ID: b824d8b27998365379963440e5d18b95ca03aa17 --- regress/unittests/sshkey/test_sshkey.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'regress/unittests') diff --git a/regress/unittests/sshkey/test_sshkey.c b/regress/unittests/sshkey/test_sshkey.c index 1aa608f92..72367bde7 100644 --- a/regress/unittests/sshkey/test_sshkey.c +++ b/regress/unittests/sshkey/test_sshkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_sshkey.c,v 1.13 2017/12/21 00:41:22 djm Exp $ */ +/* $OpenBSD: test_sshkey.c,v 1.14 2018/07/13 02:13:19 djm Exp $ */ /* * Regress test for sshkey.h key management API * @@ -434,10 +434,13 @@ sshkey_tests(void) ASSERT_PTR_NE(k1->cert->principals[1], NULL); ASSERT_PTR_NE(k1->cert->principals[2], NULL); ASSERT_PTR_NE(k1->cert->principals[3], NULL); + k1->cert->nprincipals = 4; k1->cert->valid_after = 0; k1->cert->valid_before = (u_int64_t)-1; + sshbuf_free(k1->cert->critical); k1->cert->critical = sshbuf_new(); ASSERT_PTR_NE(k1->cert->critical, NULL); + sshbuf_free(k1->cert->extensions); k1->cert->extensions = sshbuf_new(); ASSERT_PTR_NE(k1->cert->extensions, NULL); put_opt(k1->cert->critical, "force-command", "/usr/bin/true"); -- cgit v1.2.3 From 2f131e1b34502aa19f345e89cabf6fa3fc097f09 Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Mon, 16 Jul 2018 03:09:59 +0000 Subject: upstream: memleak in unittest; found by valgrind OpenBSD-Regress-ID: 168c23b0fb09fc3d0b438628990d3fd9260a8a5e --- regress/unittests/hostkeys/test_iterate.c | 37 ++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'regress/unittests') diff --git a/regress/unittests/hostkeys/test_iterate.c b/regress/unittests/hostkeys/test_iterate.c index 751825dda..d6963bd2a 100644 --- a/regress/unittests/hostkeys/test_iterate.c +++ b/regress/unittests/hostkeys/test_iterate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_iterate.c,v 1.5 2017/04/30 23:33:48 djm Exp $ */ +/* $OpenBSD: test_iterate.c,v 1.6 2018/07/16 03:09:59 djm Exp $ */ /* * Regress test for hostfile.h hostkeys_foreach() * @@ -152,6 +152,17 @@ prepare_expected(struct expected *expected, size_t n) } } +static void +cleanup_expected(struct expected *expected, size_t n) +{ + size_t i; + + for (i = 0; i < n; i++) { + sshkey_free(expected[i].l.key); + expected[i].l.key = NULL; + } +} + struct expected expected_full[] = { { NULL, -1, -1, 0, 0, 0, 0, -1, { NULL, /* path, don't care */ @@ -825,6 +836,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, NULL, NULL, ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate all without key parse"); @@ -835,6 +847,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, NULL, NULL, ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate specify host 1"); @@ -846,6 +859,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "prometheus.example.com", NULL, ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate specify host 2"); @@ -857,6 +871,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "sisyphus.example.com", NULL, ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate match host 1"); @@ -868,6 +883,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "prometheus.example.com", NULL, ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate match host 2"); @@ -879,6 +895,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "sisyphus.example.com", NULL, ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate specify host missing"); @@ -889,6 +906,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "actaeon.example.org", NULL, ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate match host missing"); @@ -899,6 +917,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "actaeon.example.org", NULL, ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate specify IPv4"); @@ -910,6 +929,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "tiresias.example.org", "192.0.2.1", ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate specify IPv6"); @@ -921,6 +941,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "tiresias.example.org", "2001:db8::1", ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate match IPv4"); @@ -932,6 +953,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "tiresias.example.org", "192.0.2.1", ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate match IPv6"); @@ -943,6 +965,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "tiresias.example.org", "2001:db8::1", ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate specify addr missing"); @@ -953,6 +976,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "tiresias.example.org", "192.168.0.1", ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate match addr missing"); @@ -963,6 +987,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "tiresias.example.org", "::1", ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate specify host 2 and IPv4"); @@ -975,6 +1000,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "sisyphus.example.com", "192.0.2.1", ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate match host 1 and IPv6"); @@ -986,7 +1012,9 @@ test_iterate(void) ctx.match_ipv6 = 1; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "prometheus.example.com", "2001:db8::1", ctx.flags), 0); + check, &ctx, "prometheus.example.com", + "2001:db8::1", ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate specify host 2 and IPv4 w/ key parse"); @@ -999,6 +1027,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "sisyphus.example.com", "192.0.2.1", ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); TEST_START("hostkeys_iterate match host 1 and IPv6 w/ key parse"); @@ -1010,7 +1039,9 @@ test_iterate(void) ctx.match_ipv6 = 1; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "prometheus.example.com", "2001:db8::1", ctx.flags), 0); + check, &ctx, "prometheus.example.com", + "2001:db8::1", ctx.flags), 0); + cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); } -- cgit v1.2.3