From 17a1f68906a0d5b9a2db7127327a533d231af393 Mon Sep 17 00:00:00 2001 From: Richard Nyberg Date: Sat, 30 Jul 2005 18:27:46 +0000 Subject: All files: Each piece must have at least one byte for their block bit array, or they will collide causing great confusion in btpd. The calculation was done wrong so this could happen for small torrents (blocks / piece < 8). policy_subr.c: * Add test for correctness. * Add missing call to cm_on_piece_full in cm_new_piece. --- cli/btcli.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'cli/btcli.c') diff --git a/cli/btcli.c b/cli/btcli.c index 874ef6a..6b5d8b1 100644 --- a/cli/btcli.c +++ b/cli/btcli.c @@ -138,9 +138,8 @@ gen_ifile(char *path) if ((errno = vopen(&fd, O_WRONLY|O_CREAT, "%s.i", path)) != 0) err(1, "opening %s.i", path); - if (ftruncate(fd, - field_len + - (off_t)ceil(mi->npieces * mi->piece_length / (double)(1<<17))) < 0) + if (ftruncate(fd, field_len + mi->npieces * + (off_t)ceil(mi->piece_length / (double)(1 << 17))) < 0) err(1, "ftruncate: %s", path); if (write(fd, cb.piece_field, field_len) != field_len) -- cgit 1.4.1