From 5d0d0f8067fb53285a38fe978cfa36dbeb53be9b Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Fri, 1 Jul 2016 22:27:24 +0200 Subject: sysdb: Use ldb_result as output in sysdb_search_ts_{users,groups} Passing address of unsigned to the output argument size_t causes access out of boundaries for type unsigned and and wrong data on big endian. It looks like functions sysdb_search_ts_{users,groups} need to store results in structure ldb_result anyway for further processing. Therefore it will be better to convert output arguments size_t* + ldb_message*** into structure ldb_result and avoid using additional helper variable with type size_t before each invocation of these functions. Reviewed-by: Sumit Bose --- src/tests/cmocka/test_sysdb_ts_cache.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) (limited to 'src/tests') diff --git a/src/tests/cmocka/test_sysdb_ts_cache.c b/src/tests/cmocka/test_sysdb_ts_cache.c index c76dd1e8e..d54922996 100644 --- a/src/tests/cmocka/test_sysdb_ts_cache.c +++ b/src/tests/cmocka/test_sysdb_ts_cache.c @@ -522,8 +522,7 @@ static void test_sysdb_group_delete(void **state) test_ctx->tctx->dom, TS_FILTER_ALL, sysdb_ts_cache_attrs, - (size_t *) &ts_res->count, - &ts_res->msgs); + ts_res); assert_int_equal(ret, ENOENT); group_attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_1); @@ -542,8 +541,7 @@ static void test_sysdb_group_delete(void **state) test_ctx->tctx->dom, TS_FILTER_ALL, sysdb_ts_cache_attrs, - (size_t *) &ts_res->count, - &ts_res->msgs); + ts_res); assert_int_equal(ret, EOK); assert_int_equal(ts_res->count, 1); @@ -562,8 +560,7 @@ static void test_sysdb_group_delete(void **state) test_ctx->tctx->dom, TS_FILTER_ALL, sysdb_ts_cache_attrs, - (size_t *) &ts_res->count, - &ts_res->msgs); + ts_res); assert_int_equal(ret, ENOENT); res = sysdb_getgrnam_res(test_ctx, test_ctx->tctx->dom, TEST_GROUP_NAME); @@ -610,8 +607,7 @@ static void test_sysdb_group_rename(void **state) test_ctx->tctx->dom, filter, sysdb_ts_cache_attrs, - (size_t *) &ts_res->count, - &ts_res->msgs); + ts_res); assert_int_equal(ret, ENOENT); talloc_free(filter); @@ -866,9 +862,8 @@ static void test_group_bysid(void **state) const char *gr_fetch_attrs[] = SYSDB_GRSRC_ATTRS; struct sysdb_attrs *group_attrs = NULL; struct ldb_result *res; - size_t msgs_count; struct ldb_message *msg = NULL; - struct ldb_message **msgs = NULL; + struct ldb_result ts_res; group_attrs = create_sidstr_attrs(test_ctx, TEST_GROUP_SID); assert_non_null(group_attrs); @@ -931,8 +926,7 @@ static void test_group_bysid(void **state) test_ctx->tctx->dom, TS_FILTER_ALL, sysdb_ts_cache_attrs, - &msgs_count, - &msgs); + &ts_res); assert_int_equal(ret, ENOENT); } @@ -1062,8 +1056,7 @@ static void test_sysdb_user_delete(void **state) test_ctx->tctx->dom, TS_FILTER_ALL, sysdb_ts_cache_attrs, - (size_t *) &ts_res->count, - &ts_res->msgs); + ts_res); assert_int_equal(ret, ENOENT); user_attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_1); @@ -1085,8 +1078,7 @@ static void test_sysdb_user_delete(void **state) test_ctx->tctx->dom, TS_FILTER_ALL, sysdb_ts_cache_attrs, - (size_t *) &ts_res->count, - &ts_res->msgs); + ts_res); assert_int_equal(ret, EOK); assert_int_equal(ts_res->count, 1); @@ -1109,8 +1101,7 @@ static void test_sysdb_user_delete(void **state) test_ctx->tctx->dom, TS_FILTER_ALL, sysdb_ts_cache_attrs, - (size_t *) &ts_res->count, - &ts_res->msgs); + ts_res); assert_int_equal(ret, ENOENT); get_pw_timestamp_attrs(test_ctx, TEST_USER_NAME, @@ -1235,9 +1226,8 @@ static void test_user_bysid(void **state) const char *pw_fetch_attrs[] = SYSDB_PW_ATTRS; struct sysdb_attrs *user_attrs = NULL; struct ldb_result *res; - size_t msgs_count; struct ldb_message *msg = NULL; - struct ldb_message **msgs = NULL; + struct ldb_result ts_res; user_attrs = create_sidstr_attrs(test_ctx, TEST_USER_SID); assert_non_null(user_attrs); @@ -1298,8 +1288,7 @@ static void test_user_bysid(void **state) test_ctx->tctx->dom, TS_FILTER_ALL, sysdb_ts_cache_attrs, - &msgs_count, - &msgs); + &ts_res); assert_int_equal(ret, ENOENT); } -- cgit