summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-09-29 07:34:30 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-09-29 07:48:55 -0400
commit5cada7fa7f822ac064f3f5d452f7f32fc4595bd4 (patch)
tree18b5a00021eda5541c53963d6d72979445d4b614
parent5ab9ed3c42781ae1911d253d56d67dc0288d55f7 (diff)
downloadsssd-5cada7fa7f822ac064f3f5d452f7f32fc4595bd4.tar.gz
sssd-5cada7fa7f822ac064f3f5d452f7f32fc4595bd4.tar.xz
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.
-rw-r--r--server/responder/nss/nsssrv_cmd.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/server/responder/nss/nsssrv_cmd.c b/server/responder/nss/nsssrv_cmd.c
index 8ca0be682..ebfd1d562 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: