]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
CVE-2020-25717 wb_sids2xids: fill cache as soon as possible
authorStefan Metzmacher <metze@samba.org>
Thu, 10 Sep 2020 21:06:02 +0000 (23:06 +0200)
committerJule Anger <janger@samba.org>
Mon, 8 Nov 2021 09:52:09 +0000 (10:52 +0100)
After adding entries to the cache we can mark them
as filled from the cache by setting its domain_index
to UINT32_MAX.

This will allow further changes to fill the results
into state->all_ids in steps.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14539

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

(cherry picked from commit 3f4626ea6d235470195918b77af35ac2cfeb227c)

source3/winbindd/wb_sids2xids.c

index cdbc70a0b49851fb2a944b0e92fdceeb7e4b7099..21bf5f901f3d2199eb4fe0b093d0ab47acf9fcd7 100644 (file)
@@ -455,6 +455,8 @@ static void wb_sids2xids_done(struct tevent_req *subreq)
                if (src->ids[si].xid.type != ID_TYPE_NOT_SPECIFIED) {
                        dst->ids[di].xid  = src->ids[si].xid;
                }
+               dst->ids[di].domain_index = UINT32_MAX; /* mark as valid */
+               idmap_cache_set_sid2unixid(&state->sids[di], &dst->ids[di].xid);
        }
 
        state->map_ids_in.num_ids = 0;
@@ -547,9 +549,6 @@ NTSTATUS wb_sids2xids_recv(struct tevent_req *req,
 
        for (i=0; i<state->num_sids; i++) {
                xids[i] = state->all_ids.ids[i].xid;
-               if (state->all_ids.ids[i].domain_index != UINT32_MAX) {
-                       idmap_cache_set_sid2unixid(&state->sids[i], &xids[i]);
-               }
        }
 
        return NT_STATUS_OK;