Skip to content

Commit

Permalink
dfs_server: randomize the server redirect set
Browse files Browse the repository at this point in the history
comply with [MS-DFSC] section 3.2.1.1

Signed-off-by: Arvid Requate <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]>
Reviewed-by: Stefan Metzmacher <[email protected]>
  • Loading branch information
reqa authored and jrasamba committed Mar 21, 2014
1 parent 6034ab5 commit cfa6fe8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions dfs_server/dfs_server_ad.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ struct dc_set {
uint32_t count;
};

static void shuffle_dc_set(struct dc_set *list)
{
uint32_t i;

srandom(time(NULL));

for (i = list->count; i > 1; i--) {
uint32_t r;
const char *tmp;

r = random() % i;

tmp = list->names[i - 1];
list->names[i - 1] = list->names[r];
list->names[r] = tmp;
}
}

/*
fill a referral type structure
*/
Expand Down Expand Up @@ -265,6 +283,8 @@ static NTSTATUS get_dcs_insite(TALLOC_CTX *ctx, struct ldb_context *ldb,
talloc_free(msg);
}

shuffle_dc_set(list);

talloc_free(r);
return NT_STATUS_OK;
}
Expand Down

0 comments on commit cfa6fe8

Please sign in to comment.