diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2009-09-29 07:34:30 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-09-29 07:48:55 -0400 |
commit | 5cada7fa7f822ac064f3f5d452f7f32fc4595bd4 (patch) | |
tree | 18b5a00021eda5541c53963d6d72979445d4b614 /server/responder | |
parent | 5ab9ed3c42781ae1911d253d56d67dc0288d55f7 (diff) | |
download | sssd-5cada7fa7f822ac064f3f5d452f7f32fc4595bd4.tar.gz sssd-5cada7fa7f822ac064f3f5d452f7f32fc4595bd4.tar.bz2 sssd-5cada7fa7f822ac064f3f5d452f7f32fc4595bd4.zip |
Fix infinite loop with empty group enumeration
Loop control variable was not being incremented.
I also converted a goto loop into a do...while loop to make it
easier to follow the logic.
Diffstat (limited to 'server/responder')
-rw-r--r-- | server/responder/nss/nsssrv_cmd.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/server/responder/nss/nsssrv_cmd.c b/server/responder/nss/nsssrv_cmd.c index 8ca0be68..ebfd1d56 100644 --- a/server/responder/nss/nsssrv_cmd.c +++ b/server/responder/nss/nsssrv_cmd.c @@ -2645,26 +2645,28 @@ static int nss_cmd_retgrent(struct cli_ctx *cctx, int num) nctx = talloc_get_type(cctx->rctx->pvt_ctx, struct nss_ctx); gctx = nctx->gctx; -retry: - if (gctx->cur >= gctx->num) goto none; - - gdom = &gctx->doms[gctx->cur]; + do { + if (gctx->cur >= gctx->num) goto none; - n = gdom->res->count - gdom->cur; - if (n == 0 && (gctx->cur+1 < gctx->num)) { - gctx->cur++; gdom = &gctx->doms[gctx->cur]; + n = gdom->res->count - gdom->cur; - } + if (n == 0 && (gctx->cur+1 < gctx->num)) { + gctx->cur++; + gdom = &gctx->doms[gctx->cur]; + n = gdom->res->count - gdom->cur; + } - if (!n) goto none; + if (!n) goto none; - msgs = &(gdom->res->msgs[gdom->cur]); + msgs = &(gdom->res->msgs[gdom->cur]); - ret = fill_grent(cctx->creq->out, gdom->domain, nctx, true, msgs, num, &n); - if (ret == ENOENT) goto retry; + ret = fill_grent(cctx->creq->out, gdom->domain, nctx, true, msgs, num, &n); + + gdom->cur += n; + + } while(ret == ENOENT); - gdom->cur += n; return ret; none: |