commit cc524d369b451f3ef10d7ca8fd091b3408d4fcdb from: Omar Polo via: Thomas Adam date: Tue May 31 23:14:47 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 - 036966bae3b46dd56ac4bdfd3f5f52d5ac280084 commit + cc524d369b451f3ef10d7ca8fd091b3408d4fcdb 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 - a12d6573a21a474223623b12bb887779abb59922 blob + 8e0ee99afbf570359d1e6fe64ef634260f6b54d7 --- lib/deltify.c +++ lib/deltify.c @@ -86,9 +86,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 * @@ -235,7 +235,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; @@ -244,7 +245,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 || @@ -266,7 +267,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; @@ -274,7 +276,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 || @@ -348,7 +350,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; @@ -377,7 +379,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) @@ -398,7 +400,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; @@ -423,7 +425,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) @@ -619,7 +621,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) { @@ -661,7 +663,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; @@ -706,7 +708,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) { @@ -748,7 +750,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; @@ -793,7 +795,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) { @@ -826,7 +828,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; @@ -868,7 +870,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) { @@ -902,7 +904,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 - e4a9e82a1782699483065c0a9646cb69be5fbbfa blob + c6b7d5c6e6410b807fa6bf0430501cfe955c5040 --- lib/pack_create.c +++ lib/pack_create.c @@ -104,7 +104,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; @@ -116,7 +116,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; @@ -682,6 +682,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++) { @@ -708,10 +711,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; @@ -745,28 +748,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); } @@ -856,8 +859,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) { @@ -874,7 +877,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; @@ -900,7 +903,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) @@ -953,8 +956,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; @@ -975,7 +978,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) @@ -1022,7 +1025,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); @@ -1032,7 +1035,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); @@ -1050,8 +1053,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) { @@ -1077,7 +1080,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) @@ -1085,7 +1088,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: @@ -1096,8 +1099,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) { @@ -1123,7 +1126,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; @@ -1131,16 +1134,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; @@ -1451,8 +1454,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; @@ -1481,14 +1485,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) @@ -1497,8 +1501,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; @@ -1519,7 +1523,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; @@ -1943,7 +1947,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)); @@ -1954,7 +1961,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 - 26c1c72e0bb71865bf52927d17021db51a21bc0b blob + 7770cecce2ed2736eb51b50d6e8e7f458321d244 --- regress/deltify/deltify_test.c +++ regress/deltify/deltify_test.c @@ -40,7 +40,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; @@ -69,7 +72,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; @@ -83,7 +87,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; @@ -131,7 +135,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; @@ -155,7 +162,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; @@ -169,7 +177,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; @@ -216,7 +224,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; @@ -240,7 +251,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; @@ -254,7 +266,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; @@ -302,7 +314,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; @@ -320,7 +335,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; @@ -334,7 +350,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;