The Samba-Bugzilla – Attachment 15403 Details for
Bug 14049
ldb dn crash
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
some ldb_dn explode tests
0001-ldb-add-some-dn-explode-tests.patch (text/plain), 3.09 KB, created by
Douglas Bagnall
on 2019-08-20 21:46:00 UTC
(
hide
)
Description:
some ldb_dn explode tests
Filename:
MIME Type:
Creator:
Douglas Bagnall
Created:
2019-08-20 21:46:00 UTC
Size:
3.09 KB
patch
obsolete
>From f40a78cb5d8ea6ce96fece07d3de45e0d231110d Mon Sep 17 00:00:00 2001 >From: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> >Date: Thu, 25 Jul 2019 12:09:16 +1200 >Subject: [PATCH] ldb: add some dn explode tests > >Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> >--- > lib/ldb/tests/test_ldb_dn.c | 68 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 68 insertions(+) > >diff --git a/lib/ldb/tests/test_ldb_dn.c b/lib/ldb/tests/test_ldb_dn.c >index 4965dcef575..5a0c69159be 100644 >--- a/lib/ldb/tests/test_ldb_dn.c >+++ b/lib/ldb/tests/test_ldb_dn.c >@@ -23,6 +23,7 @@ > #include <cmocka.h> > > #include <ldb.h> >+#include "ldb_private.h" > > static void test_ldb_dn_add_child_fmt(void **state) > { >@@ -105,12 +106,79 @@ static void test_ldb_dn_add_child_val2(void **state) > > } > >+struct explode_test { >+ const char *strdn; >+ int comp_num; >+ int ext_comp_num; >+ bool special; >+ bool invalid; >+ const char *linearized; >+ const char *ext_linearized; >+ bool explode_result; >+}; >+ >+static void test_ldb_dn_explode(void **state) >+{ >+ size_t i; >+ struct ldb_context *ldb = ldb_init(NULL, NULL); >+ struct explode_test tests[] = { >+ {"A=B", 1, 0, false, false, "A=B", "A=B", true}, >+ {"", 0, 0, false, false, "", "", true}, >+ {" ", -1, -1, false, false, " ", " ", false}, >+ {"<>", 0, 0, false, false, "", NULL, true}, >+ {"<", 0, 0, false, false, "", NULL, true}, >+ {"<><", 0, 0, false, false, "", NULL, true}, >+ {"<><>", 0, 0, false, false, "", NULL, true}, >+ {"A=B,C=D", 1, 0, false, false, "A=B,C=D", "A=B,C=D", true}, >+ {"x=ð¥", 0, 0, false, false, "x=ð¥", "x=ð¥", true}, >+ }; >+ >+ >+ for (i = 0; i < ARRAY_SIZE(tests); i++) { >+ bool result; >+ const char *linear; >+ const char *ext_linear; >+ struct ldb_dn *dn = ldb_dn_new(ldb, ldb, tests[i].strdn); >+ >+ /* >+ * special, invalid, linear, and ext_linear are set before >+ * explode >+ */ >+ fprintf(stderr, "%zu «%s»: ", i, tests[i].strdn); >+ linear = ldb_dn_get_linearized(dn); >+ assert_true((linear == NULL) == (tests[i].linearized == NULL)); >+ assert_string_equal(linear, >+ tests[i].linearized); >+ >+ ext_linear = ldb_dn_get_extended_linearized(ldb, dn, 1); >+ assert_true((ext_linear == NULL) == >+ (tests[i].ext_linearized == NULL)); >+ >+ assert_string_equal(ext_linear, >+ tests[i].ext_linearized); >+ assert_true(ldb_dn_is_special(dn) == tests[i].special); >+ assert_true(ldb_dn_is_valid(dn) != tests[i].invalid); >+ >+ /* comp nums are set by explode */ >+ result = ldb_dn_validate(dn); >+ fprintf(stderr, "res %i lin «%s» ext «%s»\n", >+ result, linear, ext_linear); >+ >+ assert_true(result == tests[i].explode_result); >+ assert_int_equal(ldb_dn_get_comp_num(dn), >+ tests[i].comp_num); >+ assert_int_equal(ldb_dn_get_extended_comp_num(dn), >+ tests[i].ext_comp_num); >+ } >+} >+ > int main(void) { > const struct CMUnitTest tests[] = { > cmocka_unit_test(test_ldb_dn_add_child_fmt), > cmocka_unit_test(test_ldb_dn_add_child_fmt2), > cmocka_unit_test(test_ldb_dn_add_child_val), > cmocka_unit_test(test_ldb_dn_add_child_val2), >+ cmocka_unit_test(test_ldb_dn_explode), > }; > > return cmocka_run_group_tests(tests, NULL, NULL); >-- >2.20.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 14049
:
15323
|
15327
|
15328
|
15330
|
15378
| 15403