use random seeds for murmurhash2 change the three hardcoded seeds to fresh ones generated on demand via arc4random. Suggested/fixed by and ok stsp@
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
diff --git a/lib/bloom.c b/lib/bloom.c
index 05e57b1..a66c49e 100644
--- a/lib/bloom.c
+++ b/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, double error)
{
bloom->ready = 0;
+ bloom->seed = arc4random();
+
if (entries < 1000 || error == 0) {
return 1;
}
diff --git a/lib/bloom.h b/lib/bloom.h
index 28356e3..51c848e 100644
--- a/lib/bloom.h
+++ b/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
diff --git a/lib/deltify.c b/lib/deltify.c
index b3bbf0b..0674100 100644
--- a/lib/deltify.c
+++ b/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, off_t file_offset0,
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_delta_table *dt,
*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_delta_table *dt,
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 got_delta_table *dt,
*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 fileoffset, off_t filesize)
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, off_t fileoffset,
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, uint8_t *data,
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_offset0, off_t basefile_size,
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 *ndeltas,
}
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 *ndeltas,
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 **deltas, int *ndeltas,
}
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 **deltas, int *ndeltas,
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 **deltas, int *ndeltas,
}
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 **deltas, int *ndeltas,
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 **deltas, int *ndeltas,
break;
}
err = lookupblk_mem(&block, dt, data + fileoffset, blocklen,
- basedata, basefile_offset0);
+ seed, basedata, basefile_offset0);
if (err)
break;
if (block != NULL) {
diff --git a/lib/got_lib_deltify.h b/lib/got_lib_deltify.h
index 7684d9c..23d51d6 100644
--- a/lib/got_lib_deltify.h
+++ b/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);
diff --git a/lib/pack_create.c b/lib/pack_create.c
index 8c93020..bb8a404 100644
--- a/lib/pack_create.c
+++ b/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_object_id *id,
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, int ncolored,
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, int ncolored,
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, int ncolored,
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 *idset,
}
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 want_meta,
} 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 *idset,
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 *idset,
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 *idset,
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 *idset,
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 *idset,
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 *ntrees,
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 *ntrees,
}
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 *ntrees,
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,6 +1948,9 @@ 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;
diff --git a/regress/deltify/deltify_test.c b/regress/deltify/deltify_test.c
index b4e7945..7dd83f6 100644
--- a/regress/deltify/deltify_test.c
+++ b/regress/deltify/deltify_test.c
@@ -42,6 +42,9 @@ 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)
@@ -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,6 +137,9 @@ 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)
@@ -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,6 +226,9 @@ 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)
@@ -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,6 +316,9 @@ 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)
@@ -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;