s3:auth: fix potential gap creation in wbcsids_to_samr_RidWithAttributeArray()
authorStefan Metzmacher <metze@samba.org>
Wed, 1 Feb 2012 16:02:52 +0000 (17:02 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 2 Feb 2012 10:25:08 +0000 (11:25 +0100)
Pair-Programmed-With: Michael Adam <obnox@samba.org>

metze

source3/auth/server_info.c

index 6c2723d699f6882d8e153ed724d51a06978e8bd8..2f764733c235741fed3ec7675f6090b4c9e5f983 100644 (file)
@@ -519,7 +519,7 @@ static NTSTATUS wbcsids_to_samr_RidWithAttributeArray(
                                const struct wbcSidWithAttr *sids,
                                size_t num_sids)
 {
-       unsigned int i;
+       unsigned int i, j = 0;
        bool ok;
 
        groups->rids = talloc_array(mem_ctx,
@@ -532,15 +532,16 @@ static NTSTATUS wbcsids_to_samr_RidWithAttributeArray(
        for (i = 0; i < num_sids; i++) {
                ok = sid_peek_check_rid(domain_sid,
                                        (const struct dom_sid *)&sids[i].sid,
-                                       &groups->rids[i].rid);
+                                       &groups->rids[j].rid);
                if (!ok) continue;
 
-               groups->rids[i].attributes = SE_GROUP_MANDATORY |
+               groups->rids[j].attributes = SE_GROUP_MANDATORY |
                                             SE_GROUP_ENABLED_BY_DEFAULT |
                                             SE_GROUP_ENABLED;
-               groups->count++;
+               j++;
        }
 
+       groups->count = j;
        return NT_STATUS_OK;
 }