commit d6a28ffe187127e3247254d7e242bb52d66eb26b from: Omar Polo date: Fri May 20 21:21:42 2022 UTC use random seeds for murmurhash2 change the three hardcoded seeds to fresh ones generated on demand via arc4random. Suggested/fixed by and ok stsp@ commit - 17cfdba68dcb4432269af930abb1f9fb9ee48e97 commit + d6a28ffe187127e3247254d7e242bb52d66eb26b blob - 05e57b1f7053a73112d4713be722a197307866e2 blob + a66c49edad2dad5800dbe4eb0deb37ed923834ac --- lib/bloom.c +++ lib/bloom.c @@ -77,7 +77,7 @@ static int bloom_check_add(struct bloom * bloom, } int hits = 0; - register unsigned int a = murmurhash2(buffer, len, 0x9747b28c); + register unsigned int a = murmurhash2(buffer, len, bloom->seed); register unsigned int b = murmurhash2(buffer, len, a); register unsigned int x; register unsigned int i; @@ -111,6 +111,8 @@ int bloom_init(struct bloom * bloom, int entries, doub { bloom->ready = 0; + bloom->seed = arc4random(); + if (entries < 1000 || error == 0) { return 1; } blob - 28356e3721b9f7902763322750d5a1b87640cd4d blob + 51c848e8470bd02ed14a2bc377a173e39836239c --- lib/bloom.h +++ lib/bloom.h @@ -52,6 +52,7 @@ struct bloom int bits; int bytes; int hashes; + uint32_t seed; // Fields below are private to the implementation. These may go away or // change incompatibly at any moment. Client code MUST NOT access or rely blob - b3bbf0b189575c109c8b935c3519ade298fed3aa blob + 0674100de40bf388b34dec547fb8529e9ba5096a --- lib/deltify.c +++ lib/deltify.c @@ -88,9 +88,9 @@ static const uint32_t geartab[256] = { }; static uint32_t -hashblk(const unsigned char *p, off_t n) +hashblk(const unsigned char *p, off_t n, uint32_t seed) { - return murmurhash2(p, n, 0x1d7c5ac3); + return murmurhash2(p, n, seed); } static const struct got_error * @@ -237,7 +237,8 @@ addblk_mem(struct got_delta_table *dt, uint8_t *data, static const struct got_error * lookupblk(struct got_delta_block **block, struct got_delta_table *dt, - unsigned char *p, off_t len, FILE *basefile, off_t basefile_offset0) + unsigned char *p, off_t len, uint32_t seed, FILE *basefile, + off_t basefile_offset0) { int i; uint32_t h; @@ -246,7 +247,7 @@ lookupblk(struct got_delta_block **block, struct got_d *block = NULL; - h = hashblk(p, len); + h = hashblk(p, len, seed); for (i = h % dt->nalloc; dt->blocks[i].len != 0; i = (i + 1) % dt->nalloc) { if (dt->blocks[i].hash != h || @@ -268,7 +269,8 @@ lookupblk(struct got_delta_block **block, struct got_d static const struct got_error * lookupblk_mem(struct got_delta_block **block, struct got_delta_table *dt, - unsigned char *p, off_t len, uint8_t *basedata, off_t basefile_offset0) + unsigned char *p, off_t len, uint32_t seed, uint8_t *basedata, + off_t basefile_offset0) { int i; uint32_t h; @@ -276,7 +278,7 @@ lookupblk_mem(struct got_delta_block **block, struct g *block = NULL; - h = hashblk(p, len); + h = hashblk(p, len, seed); for (i = h % dt->nalloc; dt->blocks[i].len != 0; i = (i + 1) % dt->nalloc) { if (dt->blocks[i].hash != h || @@ -350,7 +352,7 @@ nextblk_mem(off_t *blocklen, uint8_t *data, off_t file const struct got_error * got_deltify_init(struct got_delta_table **dt, FILE *f, off_t fileoffset, - off_t filesize) + off_t filesize, uint32_t seed) { const struct got_error *err = NULL; uint32_t h; @@ -379,7 +381,7 @@ got_deltify_init(struct got_delta_table **dt, FILE *f, goto done; if (blocklen == 0) break; - h = hashblk(buf, blocklen); + h = hashblk(buf, blocklen, seed); err = addblk(*dt, f, offset0, blocklen, fileoffset - offset0, h); if (err) @@ -400,7 +402,7 @@ done: const struct got_error * got_deltify_init_mem(struct got_delta_table **dt, uint8_t *data, - off_t fileoffset, off_t filesize) + off_t fileoffset, off_t filesize, uint32_t seed) { const struct got_error *err = NULL; uint32_t h; @@ -425,7 +427,7 @@ got_deltify_init_mem(struct got_delta_table **dt, uint goto done; if (blocklen == 0) break; - h = hashblk(data + fileoffset, blocklen); + h = hashblk(data + fileoffset, blocklen, seed); err = addblk_mem(*dt, data, offset0, blocklen, fileoffset - offset0, h); if (err) @@ -621,7 +623,7 @@ stretchblk_mem_mem(uint8_t *basedata, off_t base_offse const struct got_error * got_deltify(struct got_delta_instruction **deltas, int *ndeltas, - FILE *f, off_t fileoffset, off_t filesize, + FILE *f, off_t fileoffset, off_t filesize, uint32_t seed, struct got_delta_table *dt, FILE *basefile, off_t basefile_offset0, off_t basefile_size) { @@ -663,7 +665,7 @@ got_deltify(struct got_delta_instruction **deltas, int } break; } - err = lookupblk(&block, dt, buf, blocklen, basefile, + err = lookupblk(&block, dt, buf, blocklen, seed, basefile, basefile_offset0); if (err) break; @@ -708,7 +710,7 @@ got_deltify(struct got_delta_instruction **deltas, int const struct got_error * got_deltify_file_mem(struct got_delta_instruction **deltas, int *ndeltas, - FILE *f, off_t fileoffset, off_t filesize, + FILE *f, off_t fileoffset, off_t filesize, uint32_t seed, struct got_delta_table *dt, uint8_t *basedata, off_t basefile_offset0, off_t basefile_size) { @@ -750,7 +752,7 @@ got_deltify_file_mem(struct got_delta_instruction **de } break; } - err = lookupblk_mem(&block, dt, buf, blocklen, basedata, + err = lookupblk_mem(&block, dt, buf, blocklen, seed, basedata, basefile_offset0); if (err) break; @@ -795,7 +797,7 @@ got_deltify_file_mem(struct got_delta_instruction **de const struct got_error * got_deltify_mem_file(struct got_delta_instruction **deltas, int *ndeltas, - uint8_t *data, off_t fileoffset, off_t filesize, + uint8_t *data, off_t fileoffset, off_t filesize, uint32_t seed, struct got_delta_table *dt, FILE *basefile, off_t basefile_offset0, off_t basefile_size) { @@ -828,7 +830,7 @@ got_deltify_mem_file(struct got_delta_instruction **de } break; } - err = lookupblk(&block, dt, data + fileoffset, blocklen, + err = lookupblk(&block, dt, data + fileoffset, blocklen, seed, basefile, basefile_offset0); if (err) break; @@ -870,7 +872,7 @@ got_deltify_mem_file(struct got_delta_instruction **de const struct got_error * got_deltify_mem_mem(struct got_delta_instruction **deltas, int *ndeltas, - uint8_t *data, off_t fileoffset, off_t filesize, + uint8_t *data, off_t fileoffset, off_t filesize, uint32_t seed, struct got_delta_table *dt, uint8_t *basedata, off_t basefile_offset0, off_t basefile_size) { @@ -904,7 +906,7 @@ got_deltify_mem_mem(struct got_delta_instruction **del break; } err = lookupblk_mem(&block, dt, data + fileoffset, blocklen, - basedata, basefile_offset0); + seed, basedata, basefile_offset0); if (err) break; if (block != NULL) { blob - 7684d9c73d840e516657120dba99af61a25b5bc0 blob + 23d51d665edd5927c4b9ca18e2ebebf3473b1795 --- lib/got_lib_deltify.h +++ lib/got_lib_deltify.h @@ -37,27 +37,29 @@ enum { GOT_DELTIFY_MINCHUNK = 32, GOT_DELTIFY_MAXCHUNK = 8192, GOT_DELTIFY_SPLITMASK = (1 << 8) - 1, - }; const struct got_error *got_deltify_init(struct got_delta_table **dt, FILE *f, - off_t fileoffset, off_t filesize); + off_t fileoffset, off_t filesize, uint32_t seed); const struct got_error *got_deltify_init_mem(struct got_delta_table **dt, - uint8_t *data, off_t fileoffset, off_t filesize); + uint8_t *data, off_t fileoffset, off_t filesize, uint32_t seed); const struct got_error *got_deltify(struct got_delta_instruction **deltas, - int *ndeltas, FILE *f, off_t fileoffset, off_t filesize, + int *ndeltas, FILE *f, off_t fileoffset, off_t filesize, uint32_t seed, struct got_delta_table *dt, FILE *basefile, off_t basefile_offset0, off_t basefile_size); const struct got_error *got_deltify_file_mem( struct got_delta_instruction **deltas, int *ndeltas, - FILE *f, off_t fileoffset, off_t filesize, struct got_delta_table *dt, - uint8_t *basedata, off_t basefile_offset0, off_t basefile_size); + FILE *f, off_t fileoffset, off_t filesize, uint32_t seed, + struct got_delta_table *dt, uint8_t *basedata, off_t basefile_offset0, + off_t basefile_size); const struct got_error *got_deltify_mem_file( struct got_delta_instruction **deltas, int *ndeltas, - uint8_t *data, off_t fileoffset, off_t filesize, struct got_delta_table *dt, - FILE *basefile, off_t basefile_offset0, off_t basefile_size); + uint8_t *data, off_t fileoffset, off_t filesize, uint32_t seed, + struct got_delta_table *dt, FILE *basefile, off_t basefile_offset0, + off_t basefile_size); const struct got_error *got_deltify_mem_mem( struct got_delta_instruction **deltas, int *ndeltas, - uint8_t *data, off_t fileoffset, off_t filesize, struct got_delta_table *dt, - uint8_t *basedata, off_t basefile_offset0, off_t basefile_size); + uint8_t *data, off_t fileoffset, off_t filesize, uint32_t seed, + struct got_delta_table *dt, uint8_t *basedata, off_t basefile_offset0, + off_t basefile_size); void got_deltify_free(struct got_delta_table *dt); blob - 8c9302025ad3ff911a082225ffd55fe3627b4c48 blob + bb8a404c064277aaedb6f0a5bd168e7765442df7 --- lib/pack_create.c +++ lib/pack_create.c @@ -105,7 +105,7 @@ struct got_pack_metavec { static const struct got_error * alloc_meta(struct got_pack_meta **new, struct got_object_id *id, - const char *path, int obj_type, time_t mtime) + const char *path, int obj_type, time_t mtime, uint32_t seed) { struct got_pack_meta *m; @@ -117,7 +117,7 @@ alloc_meta(struct got_pack_meta **new, struct got_obje memcpy(&m->id, id, sizeof(m->id)); - m->path_hash = murmurhash2(path, strlen(path), 0xd70af26a); + m->path_hash = murmurhash2(path, strlen(path), seed); m->obj_type = obj_type; m->mtime = mtime; *new = m; @@ -683,6 +683,9 @@ pick_deltas(struct got_pack_meta **meta, int nmeta, in size_t delta_memsize = 0; const size_t max_delta_memsize = 4 * GOT_DELTA_RESULT_SIZE_CACHED_MAX; int outfd = -1; + uint32_t delta_seed; + + delta_seed = arc4random(); qsort(meta, nmeta, sizeof(struct got_pack_meta *), delta_order_cmp); for (i = 0; i < nmeta; i++) { @@ -709,10 +712,10 @@ pick_deltas(struct got_pack_meta **meta, int nmeta, in if (raw->f == NULL) { err = got_deltify_init_mem(&m->dtab, raw->data, - raw->hdrlen, raw->size + raw->hdrlen); + raw->hdrlen, raw->size + raw->hdrlen, delta_seed); } else { err = got_deltify_init(&m->dtab, raw->f, raw->hdrlen, - raw->size + raw->hdrlen); + raw->size + raw->hdrlen, delta_seed); } if (err) goto done; @@ -746,28 +749,28 @@ pick_deltas(struct got_pack_meta **meta, int nmeta, in if (raw->f == NULL && base_raw->f == NULL) { err = got_deltify_mem_mem(&deltas, &ndeltas, raw->data, raw->hdrlen, - raw->size + raw->hdrlen, + raw->size + raw->hdrlen, delta_seed, base->dtab, base_raw->data, base_raw->hdrlen, base_raw->size + base_raw->hdrlen); } else if (raw->f == NULL) { err = got_deltify_mem_file(&deltas, &ndeltas, raw->data, raw->hdrlen, - raw->size + raw->hdrlen, + raw->size + raw->hdrlen, delta_seed, base->dtab, base_raw->f, base_raw->hdrlen, base_raw->size + base_raw->hdrlen); } else if (base_raw->f == NULL) { err = got_deltify_file_mem(&deltas, &ndeltas, raw->f, raw->hdrlen, - raw->size + raw->hdrlen, + raw->size + raw->hdrlen, delta_seed, base->dtab, base_raw->data, base_raw->hdrlen, base_raw->size + base_raw->hdrlen); } else { err = got_deltify(&deltas, &ndeltas, raw->f, raw->hdrlen, - raw->size + raw->hdrlen, + raw->size + raw->hdrlen, delta_seed, base->dtab, base_raw->f, base_raw->hdrlen, base_raw->size + base_raw->hdrlen); } @@ -857,8 +860,8 @@ search_packidx(int *found, struct got_object_id *id, static const struct got_error * add_object(int want_meta, struct got_object_idset *idset, struct got_object_id *id, const char *path, int obj_type, - time_t mtime, int loose_obj_only, struct got_repository *repo, - int *ncolored, int *nfound, int *ntrees, + time_t mtime, uint32_t seed, int loose_obj_only, + struct got_repository *repo, int *ncolored, int *nfound, int *ntrees, got_pack_progress_cb progress_cb, void *progress_arg, struct got_ratelimit *rl) { @@ -875,7 +878,7 @@ add_object(int want_meta, struct got_object_idset *ids } if (want_meta) { - err = alloc_meta(&m, id, path, obj_type, mtime); + err = alloc_meta(&m, id, path, obj_type, mtime, seed); if (err) return err; @@ -901,7 +904,7 @@ static const struct got_error * load_tree_entries(struct got_object_id_queue *ids, int want_meta, struct got_object_idset *idset, struct got_object_idset *idset_exclude, struct got_object_id *tree_id, - const char *dpath, time_t mtime, struct got_repository *repo, + const char *dpath, time_t mtime, uint32_t seed, struct got_repository *repo, int loose_obj_only, int *ncolored, int *nfound, int *ntrees, got_pack_progress_cb progress_cb, void *progress_arg, struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg) @@ -954,8 +957,8 @@ load_tree_entries(struct got_object_id_queue *ids, int } else if (S_ISREG(mode) || S_ISLNK(mode)) { err = add_object(want_meta, want_meta ? idset : idset_exclude, id, p, - GOT_OBJ_TYPE_BLOB, mtime, loose_obj_only, repo, - ncolored, nfound, ntrees, + GOT_OBJ_TYPE_BLOB, mtime, seed, loose_obj_only, + repo, ncolored, nfound, ntrees, progress_cb, progress_arg, rl); if (err) break; @@ -976,7 +979,7 @@ static const struct got_error * load_tree(int want_meta, struct got_object_idset *idset, struct got_object_idset *idset_exclude, struct got_object_id *tree_id, const char *dpath, time_t mtime, - struct got_repository *repo, int loose_obj_only, + uint32_t seed, struct got_repository *repo, int loose_obj_only, int *ncolored, int *nfound, int *ntrees, got_pack_progress_cb progress_cb, void *progress_arg, struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg) @@ -1023,7 +1026,7 @@ load_tree(int want_meta, struct got_object_idset *idse err = add_object(want_meta, want_meta ? idset : idset_exclude, &qid->id, path, GOT_OBJ_TYPE_TREE, - mtime, loose_obj_only, repo, + mtime, seed, loose_obj_only, repo, ncolored, nfound, ntrees, progress_cb, progress_arg, rl); if (err) { free(qid->data); @@ -1033,7 +1036,7 @@ load_tree(int want_meta, struct got_object_idset *idse err = load_tree_entries(&tree_ids, want_meta, idset, idset_exclude, &qid->id, - path, mtime, repo, loose_obj_only, ncolored, nfound, + path, mtime, seed, repo, loose_obj_only, ncolored, nfound, ntrees, progress_cb, progress_arg, rl, cancel_cb, cancel_arg); free(qid->data); @@ -1051,8 +1054,8 @@ load_tree(int want_meta, struct got_object_idset *idse static const struct got_error * load_commit(int want_meta, struct got_object_idset *idset, struct got_object_idset *idset_exclude, - struct got_object_id *id, struct got_repository *repo, int loose_obj_only, - int *ncolored, int *nfound, int *ntrees, + struct got_object_id *id, struct got_repository *repo, uint32_t seed, + int loose_obj_only, int *ncolored, int *nfound, int *ntrees, got_pack_progress_cb progress_cb, void *progress_arg, struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg) { @@ -1078,7 +1081,7 @@ load_commit(int want_meta, struct got_object_idset *id err = add_object(want_meta, want_meta ? idset : idset_exclude, id, "", GOT_OBJ_TYPE_COMMIT, - got_object_commit_get_committer_time(commit), + got_object_commit_get_committer_time(commit), seed, loose_obj_only, repo, ncolored, nfound, ntrees, progress_cb, progress_arg, rl); if (err) @@ -1086,7 +1089,7 @@ load_commit(int want_meta, struct got_object_idset *id err = load_tree(want_meta, idset, idset_exclude, got_object_commit_get_tree_id(commit), - "", got_object_commit_get_committer_time(commit), + "", got_object_commit_get_committer_time(commit), seed, repo, loose_obj_only, ncolored, nfound, ntrees, progress_cb, progress_arg, rl, cancel_cb, cancel_arg); done: @@ -1097,8 +1100,8 @@ done: static const struct got_error * load_tag(int want_meta, struct got_object_idset *idset, struct got_object_idset *idset_exclude, - struct got_object_id *id, struct got_repository *repo, int loose_obj_only, - int *ncolored, int *nfound, int *ntrees, + struct got_object_id *id, struct got_repository *repo, uint32_t seed, + int loose_obj_only, int *ncolored, int *nfound, int *ntrees, got_pack_progress_cb progress_cb, void *progress_arg, struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg) { @@ -1124,7 +1127,7 @@ load_tag(int want_meta, struct got_object_idset *idset err = add_object(want_meta, want_meta ? idset : idset_exclude, id, "", GOT_OBJ_TYPE_TAG, - got_object_tag_get_tagger_time(tag), loose_obj_only, repo, + got_object_tag_get_tagger_time(tag), seed, loose_obj_only, repo, ncolored, nfound, ntrees, progress_cb, progress_arg, rl); if (err) goto done; @@ -1132,16 +1135,16 @@ load_tag(int want_meta, struct got_object_idset *idset switch (got_object_tag_get_object_type(tag)) { case GOT_OBJ_TYPE_COMMIT: err = load_commit(want_meta, idset, idset_exclude, - got_object_tag_get_object_id(tag), repo, loose_obj_only, - ncolored, nfound, ntrees, progress_cb, progress_arg, rl, - cancel_cb, cancel_arg); + got_object_tag_get_object_id(tag), repo, seed, + loose_obj_only, ncolored, nfound, ntrees, + progress_cb, progress_arg, rl, cancel_cb, cancel_arg); break; case GOT_OBJ_TYPE_TREE: err = load_tree(want_meta, idset, idset_exclude, got_object_tag_get_object_id(tag), "", - got_object_tag_get_tagger_time(tag), repo, loose_obj_only, - ncolored, nfound, ntrees, progress_cb, progress_arg, rl, - cancel_cb, cancel_arg); + got_object_tag_get_tagger_time(tag), seed, repo, + loose_obj_only, ncolored, nfound, ntrees, + progress_cb, progress_arg, rl, cancel_cb, cancel_arg); break; default: break; @@ -1452,8 +1455,9 @@ static const struct got_error * load_object_ids(int *ncolored, int *nfound, int *ntrees, struct got_object_idset *idset, struct got_object_id **theirs, int ntheirs, struct got_object_id **ours, int nours, struct got_repository *repo, - int loose_obj_only, got_pack_progress_cb progress_cb, void *progress_arg, - struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg) + uint32_t seed, int loose_obj_only, got_pack_progress_cb progress_cb, + void *progress_arg, struct got_ratelimit *rl, got_cancel_cb cancel_cb, + void *cancel_arg) { const struct got_error *err = NULL; struct got_object_id **ids = NULL; @@ -1482,14 +1486,14 @@ load_object_ids(int *ncolored, int *nfound, int *ntree return err; if (obj_type == GOT_OBJ_TYPE_COMMIT) { err = load_commit(0, idset, idset_exclude, id, repo, - loose_obj_only, ncolored, nfound, ntrees, + seed, loose_obj_only, ncolored, nfound, ntrees, progress_cb, progress_arg, rl, cancel_cb, cancel_arg); if (err) goto done; } else if (obj_type == GOT_OBJ_TYPE_TAG) { err = load_tag(0, idset, idset_exclude, id, repo, - loose_obj_only, ncolored, nfound, ntrees, + seed, loose_obj_only, ncolored, nfound, ntrees, progress_cb, progress_arg, rl, cancel_cb, cancel_arg); if (err) @@ -1498,8 +1502,8 @@ load_object_ids(int *ncolored, int *nfound, int *ntree } for (i = 0; i < nobj; i++) { - err = load_commit(1, idset, idset_exclude, - ids[i], repo, loose_obj_only, ncolored, nfound, ntrees, + err = load_commit(1, idset, idset_exclude, ids[i], repo, + seed, loose_obj_only, ncolored, nfound, ntrees, progress_cb, progress_arg, rl, cancel_cb, cancel_arg); if (err) goto done; @@ -1520,7 +1524,7 @@ load_object_ids(int *ncolored, int *nfound, int *ntree if (obj_type != GOT_OBJ_TYPE_TAG) continue; err = load_tag(1, idset, idset_exclude, id, repo, - loose_obj_only, ncolored, nfound, ntrees, + seed, loose_obj_only, ncolored, nfound, ntrees, progress_cb, progress_arg, rl, cancel_cb, cancel_arg); if (err) goto done; @@ -1944,7 +1948,10 @@ got_pack_create(uint8_t *packsha1, FILE *packfile, struct got_pack_metavec deltify, reuse; int ncolored = 0, nfound = 0, ntrees = 0; size_t ndeltify; + uint32_t seed; + seed = arc4random(); + memset(&deltify, 0, sizeof(deltify)); memset(&reuse, 0, sizeof(reuse)); @@ -1955,7 +1962,7 @@ got_pack_create(uint8_t *packsha1, FILE *packfile, return got_error_from_errno("got_object_idset_alloc"); err = load_object_ids(&ncolored, &nfound, &ntrees, idset, theirs, - ntheirs, ours, nours, repo, loose_obj_only, + ntheirs, ours, nours, repo, seed, loose_obj_only, progress_cb, progress_arg, &rl, cancel_cb, cancel_arg); if (err) goto done; blob - b4e79453a7e3443c1559612f98ab36e7d8c7ca50 blob + 7dd83f68e504ef73f57bd63d2341c99537121292 --- regress/deltify/deltify_test.c +++ regress/deltify/deltify_test.c @@ -42,7 +42,10 @@ deltify_abc_axc(void) struct got_delta_instruction *deltas; int ndeltas; int have_nblocks = 0; + uint32_t seed; + seed = arc4random(); + base_file = got_opentemp(); if (base_file == NULL) return 1; @@ -71,7 +74,8 @@ deltify_abc_axc(void) rewind(base_file); rewind(derived_file); - err = got_deltify_init(&dt, base_file, 0, 3 * GOT_DELTIFY_MAXCHUNK); + err = got_deltify_init(&dt, base_file, 0, 3 * GOT_DELTIFY_MAXCHUNK, + seed); if (err) goto done; @@ -85,7 +89,7 @@ deltify_abc_axc(void) } err = got_deltify(&deltas, &ndeltas, derived_file, 0, - 3 * GOT_DELTIFY_MAXCHUNK, dt, base_file, 0, + 3 * GOT_DELTIFY_MAXCHUNK, seed, dt, base_file, 0, 3 * GOT_DELTIFY_MAXCHUNK); if (err) goto done; @@ -133,7 +137,10 @@ deltify_abc_axc_file_mem(void) struct got_delta_instruction *deltas; int ndeltas; int have_nblocks = 0; + uint32_t seed; + seed = arc4random(); + derived_file = got_opentemp(); if (derived_file == NULL) return 1; @@ -157,7 +164,8 @@ deltify_abc_axc_file_mem(void) rewind(derived_file); - err = got_deltify_init_mem(&dt, base_data, 0, 3 * GOT_DELTIFY_MAXCHUNK); + err = got_deltify_init_mem(&dt, base_data, 0, 3 * GOT_DELTIFY_MAXCHUNK, + seed); if (err) goto done; @@ -171,7 +179,7 @@ deltify_abc_axc_file_mem(void) } err = got_deltify_file_mem(&deltas, &ndeltas, derived_file, 0, - 3 * GOT_DELTIFY_MAXCHUNK, dt, base_data, 0, + 3 * GOT_DELTIFY_MAXCHUNK, seed, dt, base_data, 0, 3 * GOT_DELTIFY_MAXCHUNK); if (err) goto done; @@ -218,7 +226,10 @@ deltify_abc_axc_mem_file(void) struct got_delta_instruction *deltas; int ndeltas; int have_nblocks = 0; + uint32_t seed; + seed = arc4random(); + base_file = got_opentemp(); if (base_file == NULL) return 1; @@ -242,7 +253,8 @@ deltify_abc_axc_mem_file(void) rewind(base_file); - err = got_deltify_init(&dt, base_file, 0, 3 * GOT_DELTIFY_MAXCHUNK); + err = got_deltify_init(&dt, base_file, 0, 3 * GOT_DELTIFY_MAXCHUNK, + seed); if (err) goto done; @@ -256,7 +268,7 @@ deltify_abc_axc_mem_file(void) } err = got_deltify_mem_file(&deltas, &ndeltas, derived_file, 0, - 3 * GOT_DELTIFY_MAXCHUNK, dt, base_file, 0, + 3 * GOT_DELTIFY_MAXCHUNK, seed, dt, base_file, 0, 3 * GOT_DELTIFY_MAXCHUNK); if (err) goto done; @@ -304,7 +316,10 @@ deltify_abc_axc_mem_mem(void) struct got_delta_instruction *deltas; int ndeltas; int have_nblocks = 0; + uint32_t seed; + seed = arc4random(); + result_file = got_opentemp(); if (result_file == NULL) return 1; @@ -322,7 +337,8 @@ deltify_abc_axc_mem_mem(void) derived_file[2 * GOT_DELTIFY_MAXCHUNK + i] = 'c'; } - err = got_deltify_init_mem(&dt, base_file, 0, 3 * GOT_DELTIFY_MAXCHUNK); + err = got_deltify_init_mem(&dt, base_file, 0, 3 * GOT_DELTIFY_MAXCHUNK, + seed); if (err) goto done; @@ -336,7 +352,7 @@ deltify_abc_axc_mem_mem(void) } err = got_deltify_mem_mem(&deltas, &ndeltas, derived_file, 0, - 3 * GOT_DELTIFY_MAXCHUNK, dt, base_file, 0, + 3 * GOT_DELTIFY_MAXCHUNK, seed, dt, base_file, 0, 3 * GOT_DELTIFY_MAXCHUNK); if (err) goto done;