summaryrefslogtreecommitdiffstats
path: root/src/db/sysdb_ops.c
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2016-07-01 22:27:24 +0200
committerJakub Hrozek <jhrozek@redhat.com>2016-07-06 17:27:30 +0200
commit5d0d0f8067fb53285a38fe978cfa36dbeb53be9b (patch)
tree5b433b934ea4d6505a705e164073b9d637217fa2 /src/db/sysdb_ops.c
parentc7c1941f9045531044121520fc2ca0e048732c25 (diff)
downloadsssd-5d0d0f8067fb53285a38fe978cfa36dbeb53be9b.tar.gz
sssd-5d0d0f8067fb53285a38fe978cfa36dbeb53be9b.tar.xz
sssd-5d0d0f8067fb53285a38fe978cfa36dbeb53be9b.zip
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 <sbose@redhat.com>
Diffstat (limited to 'src/db/sysdb_ops.c')
-rw-r--r--src/db/sysdb_ops.c46
1 files changed, 38 insertions, 8 deletions
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 9ee8f6fd9..34e8a5ef4 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -3440,15 +3440,30 @@ int sysdb_search_ts_users(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
const char *sub_filter,
const char **attrs,
- size_t *msgs_count,
- struct ldb_message ***msgs)
+ struct ldb_result *res)
{
+ size_t msgs_count;
+ struct ldb_message **msgs;
+ int ret;
+
+ if (res == NULL) {
+ return EINVAL;
+ }
+
+ ZERO_STRUCT(*res);
+
if (domain->sysdb->ldb_ts == NULL) {
return ENOENT;
}
- return sysdb_cache_search_users(mem_ctx, domain, domain->sysdb->ldb_ts,
- sub_filter, attrs, msgs_count, msgs);
+ ret = sysdb_cache_search_users(mem_ctx, domain, domain->sysdb->ldb_ts,
+ sub_filter, attrs, &msgs_count, &msgs);
+ if (ret == EOK) {
+ res->count = (unsigned)msgs_count;
+ res->msgs = msgs;
+ }
+
+ return ret;
}
/* =Delete-User-by-Name-OR-uid============================================ */
@@ -3642,15 +3657,30 @@ int sysdb_search_ts_groups(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
const char *sub_filter,
const char **attrs,
- size_t *msgs_count,
- struct ldb_message ***msgs)
+ struct ldb_result *res)
{
+ size_t msgs_count;
+ struct ldb_message **msgs;
+ int ret;
+
+ if (res == NULL) {
+ return EINVAL;
+ }
+
+ ZERO_STRUCT(*res);
+
if (domain->sysdb->ldb_ts == NULL) {
return ENOENT;
}
- return sysdb_cache_search_groups(mem_ctx, domain, domain->sysdb->ldb_ts,
- sub_filter, attrs, msgs_count, msgs);
+ ret = sysdb_cache_search_groups(mem_ctx, domain, domain->sysdb->ldb_ts,
+ sub_filter, attrs, &msgs_count, &msgs);
+ if (ret == EOK) {
+ res->count = (unsigned)msgs_count;
+ res->msgs = msgs;
+ }
+
+ return ret;
}
/* =Delete-Group-by-Name-OR-gid=========================================== */