The Samba-Bugzilla – Attachment 13371 Details for
Bug 12900
index out of bound in ldb_msg_find_common_values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
tests for the out-of-bounds on zero
0003-ldb-tests-more-thoroughly-test-empty-ldb_msg-element.patch (text/plain), 4.54 KB, created by
Douglas Bagnall
on 2017-07-13 04:39:50 UTC
(
hide
)
Description:
tests for the out-of-bounds on zero
Filename:
MIME Type:
Creator:
Douglas Bagnall
Created:
2017-07-13 04:39:50 UTC
Size:
4.54 KB
patch
obsolete
>From cc14614fd7fc43058e21c7c9d900bf3d661e0a00 Mon Sep 17 00:00:00 2001 >From: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> >Date: Thu, 6 Jul 2017 12:41:07 +1200 >Subject: [PATCH 3/3] ldb/tests: more thoroughly test empty ldb_msg elements > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12900 > >Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> >Reviewed-by: Andreas Schneider <asn@samba.org> > >Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> >Autobuild-Date(master): Fri Jul 7 20:10:37 CEST 2017 on sn-devel-144 > >(cherry picked from commit 4b3de6118569eb9a1d4f233eca112d0d207c1087) >--- > lib/ldb/tests/ldb_msg.c | 32 +++++++++++++++++++++++++++++--- > 1 file changed, 29 insertions(+), 3 deletions(-) > >diff --git a/lib/ldb/tests/ldb_msg.c b/lib/ldb/tests/ldb_msg.c >index e665d55..f8de418 100644 >--- a/lib/ldb/tests/ldb_msg.c >+++ b/lib/ldb/tests/ldb_msg.c >@@ -87,6 +87,11 @@ static void test_ldb_msg_find_duplicate_val(void **state) > ret = ldb_msg_add_empty(msg, "el1", 0, &el); > assert_int_equal(ret, LDB_SUCCESS); > >+ /* An empty message contains no duplicates */ >+ ret = ldb_msg_find_duplicate_val(NULL, test_ctx, el, &dupe, 0); >+ assert_int_equal(ret, LDB_SUCCESS); >+ assert_null(dupe); >+ > for (i = 0; i < 5; i++) { > add_uint_value(test_ctx, msg, "el1", i); > } >@@ -176,19 +181,19 @@ static void _assert_element_equal(struct ldb_message_element *a, > static void test_ldb_msg_find_common_values(void **state) > { > /* we only use the state as a talloc context */ >- struct ldb_message_element *el, *el2, *el3, *el4, *el2b; >+ struct ldb_message_element *el, *el2, *el3, *el4, *el2b, *empty; > struct ldb_message_element *orig, *orig2, *orig3, *orig4; > int ret; > const uint32_t remove_dupes = LDB_MSG_FIND_COMMON_REMOVE_DUPLICATES; > el = new_msg_element(*state, "test", 0, 4); > el2 = new_msg_element(*state, "test", 4, 4); > el3 = new_msg_element(*state, "test", 6, 4); >+ empty = new_msg_element(*state, "test", 0, 0); > orig = new_msg_element(*state, "test", 0, 4); > orig2 = new_msg_element(*state, "test", 4, 4); > orig3 = new_msg_element(*state, "test", 6, 4); > > /* first round is with short value arrays, using quadratic method */ >- > /* we expect no collisions here */ > ret = ldb_msg_find_common_values(NULL, *state, el, el2, 0); > assert_int_equal(ret, LDB_SUCCESS); >@@ -256,7 +261,7 @@ static void test_ldb_msg_find_common_values(void **state) > assert_element_equal(el2, orig2); > assert_int_equal(el3->num_values, 0); > >- /* seeing as we have an empty element, try permutations therewith. >+ /* permutations involving empty elements. > everything should succeed. */ > ret = ldb_msg_find_common_values(NULL, *state, el3, el2, 0); > assert_int_equal(ret, LDB_SUCCESS); >@@ -264,10 +269,19 @@ static void test_ldb_msg_find_common_values(void **state) > assert_int_equal(ret, LDB_SUCCESS); > ret = ldb_msg_find_common_values(NULL, *state, el2, el3, 0); > assert_int_equal(ret, LDB_SUCCESS); >+ assert_int_equal(el2->num_values, orig2->num_values); > ret = ldb_msg_find_common_values(NULL, *state, el3, el2, remove_dupes); > assert_int_equal(ret, LDB_SUCCESS); >+ assert_int_equal(el2->num_values, orig2->num_values); >+ assert_int_equal(el3->num_values, 0); /* el3 is now empty */ > ret = ldb_msg_find_common_values(NULL, *state, el2, el3, remove_dupes); > assert_int_equal(ret, LDB_SUCCESS); >+ ret = ldb_msg_find_common_values(NULL, *state, el3, empty, 0); >+ assert_int_equal(ret, LDB_SUCCESS); >+ ret = ldb_msg_find_common_values(NULL, *state, empty, empty, 0); >+ assert_int_equal(ret, LDB_SUCCESS); >+ ret = ldb_msg_find_common_values(NULL, *state, empty, el3, 0); >+ assert_int_equal(ret, LDB_SUCCESS); > > assert_element_equal(el2, orig2); > assert_element_equal(el, orig); >@@ -329,6 +343,18 @@ static void test_ldb_msg_find_common_values(void **state) > orig2 = new_msg_element(*state, "test", 12, 2); > assert_element_equal(el2, orig2); > >+ /* test the empty el against the full elements */ >+ ret = ldb_msg_find_common_values(NULL, *state, el, empty, 0); >+ assert_int_equal(ret, LDB_SUCCESS); >+ ret = ldb_msg_find_common_values(NULL, *state, empty, el, 0); >+ assert_int_equal(ret, LDB_SUCCESS); >+ ret = ldb_msg_find_common_values(NULL, *state, el, empty, remove_dupes); >+ assert_int_equal(ret, LDB_SUCCESS); >+ ret = ldb_msg_find_common_values(NULL, *state, empty, el, remove_dupes); >+ assert_int_equal(ret, LDB_SUCCESS); >+ assert_element_equal(el, orig); >+ assert_element_equal(empty, el3); >+ > /* make sure an identical element with a different name is rejected */ > el2 = new_msg_element(*state, "fish", 12, 2); > ret = ldb_msg_find_common_values(NULL, *state, el2, el, remove_dupes); >-- >2.7.4 >
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 12900
:
13369
|
13370
| 13371