URL: https://github.com/SSSD/sssd/pull/211 Author: celestian Title: #211: IFP: Fix of limit = 0 (unlimited result) Action: opened
PR body: """ If we set limit to 0 it means that result is unlimited. Internally we restrict number of result by allocation of result array. In unlimited case there was a bug and zero array was allocated. This fix allocates neccessary array when we know real result size. Resolves: https://pagure.io/SSSD/sssd/issue/3306 How to test (this reproducer needs #208 "IFP: Filter with * in Users.ListByName method" applied) ``` systemctl daemon-reload sudo su -c "truncate -s0 /var/log/sssd/*.log" sudo su -c "rm -f /var/lib/sss/db/*" sudo su -c "rm -f /var/lib/sss/mc/*" sudo systemctl restart sssd.service sudo su -c "truncate -s0 /var/log/sssd/*.log" dbus-send --system --print-reply --dest=org.freedesktop.sssd.infopipe \ /org/freedesktop/sssd/infopipe/Users \ org.freedesktop.sssd.infopipe.Users.ListByName \ string:"*" uint32:"0" dbus-send --system --print-reply --dest=org.freedesktop.sssd.infopipe \ /org/freedesktop/sssd/infopipe/Groups \ org.freedesktop.sssd.infopipe.Groups.ListByName \ string:"*" uint32:"100" dbus-send --system --print-reply --dest=org.freedesktop.sssd.infopipe \ /org/freedesktop/sssd/infopipe/Users \ org.freedesktop.sssd.infopipe.Users.ListByDomainAndName \ string:"domain.cygnus" string:"*" uint32:"100" ``` """ To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/211/head:pr211 git checkout pr211
From 224546e19e6ac3007c6fd272bdea373ae04d8c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C4=8Cech?= <pc...@redhat.com> Date: Tue, 28 Mar 2017 09:11:22 +0200 Subject: [PATCH] IFP: Fix of limit = 0 (unlimited result) If we set limit to 0 it means that result is unlimited. Internally we restrict number of result by allocation of result array. In unlimited case there was a bug and zero array was allocated. This fix allocates neccessary array when we know real result size. Resolves: https://pagure.io/SSSD/sssd/issue/3306 --- src/responder/ifp/ifp_groups.c | 10 +++++++++- src/responder/ifp/ifp_users.c | 20 ++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/responder/ifp/ifp_groups.c b/src/responder/ifp/ifp_groups.c index 94d1e84..166cfe7 100644 --- a/src/responder/ifp/ifp_groups.c +++ b/src/responder/ifp/ifp_groups.c @@ -86,7 +86,15 @@ static int ifp_groups_list_copy(struct ifp_list_ctx *list_ctx, { size_t copy_count, i; - copy_count = ifp_list_ctx_remaining_capacity(list_ctx, result->count); + if (list_ctx->limit == 0) { + list_ctx->paths = talloc_zero_array(list_ctx, const char *, result->count); + if (list_ctx->paths == NULL) { + return ENOMEM; + } + copy_count = result->count; + } else { + copy_count = ifp_list_ctx_remaining_capacity(list_ctx, result->count); + } for (i = 0; i < copy_count; i++) { list_ctx->paths[list_ctx->path_count + i] = \ diff --git a/src/responder/ifp/ifp_users.c b/src/responder/ifp/ifp_users.c index cc78300..76c9ac9 100644 --- a/src/responder/ifp/ifp_users.c +++ b/src/responder/ifp/ifp_users.c @@ -430,7 +430,15 @@ static int ifp_users_list_copy(struct ifp_list_ctx *list_ctx, { size_t copy_count, i; - copy_count = ifp_list_ctx_remaining_capacity(list_ctx, result->count); + if (list_ctx->limit == 0) { + list_ctx->paths = talloc_zero_array(list_ctx, const char *, result->count); + if (list_ctx->paths == NULL) { + return ENOMEM; + } + copy_count = result->count; + } else { + copy_count = ifp_list_ctx_remaining_capacity(list_ctx, result->count); + } for (i = 0; i < copy_count; i++) { list_ctx->paths[list_ctx->path_count + i] = \ @@ -892,7 +900,15 @@ static void ifp_users_list_by_domain_and_name_done(struct tevent_req *req) goto done; } - copy_count = ifp_list_ctx_remaining_capacity(list_ctx, result->count); + if (list_ctx->limit == 0) { + list_ctx->paths = talloc_zero_array(list_ctx, const char *, result->count); + if (list_ctx->paths == NULL) { + goto done; + } + copy_count = result->count; + } else { + copy_count = ifp_list_ctx_remaining_capacity(list_ctx, result->count); + } for (i = 0; i < copy_count; i++) { list_ctx->paths[i] = ifp_users_build_path_from_msg(list_ctx->paths,
_______________________________________________ sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org