commit - 17cfdba68dcb4432269af930abb1f9fb9ee48e97
commit + d6a28ffe187127e3247254d7e242bb52d66eb26b
blob - 05e57b1f7053a73112d4713be722a197307866e2
blob + a66c49edad2dad5800dbe4eb0deb37ed923834ac
--- lib/bloom.c
+++ lib/bloom.c
}
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;
{
bloom->ready = 0;
+ bloom->seed = arc4random();
+
if (entries < 1000 || error == 0) {
return 1;
}
blob - 28356e3721b9f7902763322750d5a1b87640cd4d
blob + 51c848e8470bd02ed14a2bc377a173e39836239c
--- lib/bloom.h
+++ lib/bloom.h
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
};
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 *
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;
*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 ||
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;
*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 ||
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;
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)
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;
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)
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)
{
}
break;
}
- err = lookupblk(&block, dt, buf, blocklen, basefile,
+ err = lookupblk(&block, dt, buf, blocklen, seed, basefile,
basefile_offset0);
if (err)
break;
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)
{
}
break;
}
- err = lookupblk_mem(&block, dt, buf, blocklen, basedata,
+ err = lookupblk_mem(&block, dt, buf, blocklen, seed, basedata,
basefile_offset0);
if (err)
break;
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)
{
}
break;
}
- err = lookupblk(&block, dt, data + fileoffset, blocklen,
+ err = lookupblk(&block, dt, data + fileoffset, blocklen, seed,
basefile, basefile_offset0);
if (err)
break;
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)
{
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
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
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;
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;
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++) {
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;
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);
}
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)
{
}
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;
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)
} 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;
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)
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);
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);
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)
{
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)
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:
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)
{
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;
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;
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;
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)
}
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;
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;
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));
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
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;
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;
}
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;
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;
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;
}
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;
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;
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;
}
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;
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;
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;
}
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;