Skip to content

Commit

Permalink
Shuffle the order in which Manifest entries are processed
Browse files Browse the repository at this point in the history
Previously work items were enqueued in the order the CA intended them
to appear on a Manifest. However, there is no obvious benefit to letting
third parties decide the order in which objects are processed.

Instead, randomize the list of FileAndHashes, its ordering has no meaning
anyway. As they say, a fox is not taken twice in the same snare
  • Loading branch information
job committed Jun 13, 2024
1 parent 5b707aa commit 7088ea4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/object/manifest.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <stdlib.h>

#include "object/manifest.h"

#include "algorithm.h"
Expand Down Expand Up @@ -192,15 +194,24 @@ build_rpp(struct Manifest *mft, struct rpki_uri *notif,
struct rpki_uri *mft_uri, struct rpp **pp)
{
char const *tal;
int i;
struct FileAndHash *fah;
int i, j;
struct FileAndHash *fah, *tmpfah;
struct rpki_uri *uri;
int error;

*pp = rpp_create();

tal = tal_get_file_name(validation_tal(state_retrieve()));

/* Fisher-Yates shuffle with modulo bias */
srand(time(NULL) ^ getpid());
for (i = 0; i < mft->fileList.list.count; i++) {
j = rand() % mft->fileList.list.count;
tmpfah = mft->fileList.list.array[j];
mft->fileList.list.array[j] = mft->fileList.list.array[i];
mft->fileList.list.array[i] = tmpfah;
}

for (i = 0; i < mft->fileList.list.count; i++) {
fah = mft->fileList.list.array[i];

Expand Down

0 comments on commit 7088ea4

Please sign in to comment.