62 lines
1.8 KiB
Diff
62 lines
1.8 KiB
Diff
|
From 5cada7fa7f822ac064f3f5d452f7f32fc4595bd4 Mon Sep 17 00:00:00 2001
|
||
|
From: Stephen Gallagher <sgallagh@redhat.com>
|
||
|
Date: Tue, 29 Sep 2009 07:34:30 -0400
|
||
|
Subject: [PATCH 2/2] 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.
|
||
|
---
|
||
|
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 8ca0be6..ebfd1d5 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:
|
||
|
--
|
||
|
1.6.2.5
|
||
|
|