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.

This should fix https://fedorahosted.org/sssd/ticket/211

I tested with a single LOCAL domain, specified as in the ticket, and
also with a second, LDAP domain to verify that groups were still
enumerated for further domains.
-- 
Stephen Gallagher
RHCE 804006346421761

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/
From 6b0bdf65566b5a37925b76e0db2b1967e5bf3547 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <[email protected]>
Date: Tue, 29 Sep 2009 07:34:30 -0400
Subject: [PATCH] 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

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
sssd-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to