libeech

BitTorrent library
git clone git://z3bra.org/libeech.git
Log | Files | Refs | README | LICENSE

commit e4776677ff079bc800b63a77587528bae051067b
parent ac6b3082a4dcd6694b7171658356d7bb917f1097
Author: z3bra <contactatz3bradotorg>
Date:   Wed Jul  4 08:53:34 +0200

Correctly set bitfield, and actually send it

Diffstat:
libeech.c | 5++++-
libeech.h | 4++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/libeech.c b/libeech.c @@ -511,6 +511,9 @@ pwptxbf(struct torrent *t, struct peer *p) /* Message type */ m[4] = BITFIELD; + /* Bitfield */ + memcpy(m+5, t->bf, l); + return pwpsend(p, m, l + 5); } @@ -800,7 +803,7 @@ glch_loadtorrent(struct torrent *t, char *b, size_t s) t->npiece = t->sz / t->psz + !!(t->sz % t->psz); bekstr(&t->info, "pieces", 6, &v); memcpy(t->ph, v.off, v.end - v.off); - memset(t->bf, 0, t->npiece / 8 + 1); + memset(t->bf, 0, PCENUM / 8); for (i = 0; i < t->npiece; i++) { if (readpiece(t, &piece, i) > 0 && !chkpiece(t, &piece, i)) diff --git a/libeech.h b/libeech.h @@ -24,8 +24,8 @@ struct piece { int n; ssize_t sz; char blks[PCESIZ]; - char bf[PCESIZ / BLKSIZ]; - char rq[PCESIZ / BLKSIZ]; + char bf[PCENUM / 8]; + char rq[PCENUM / 8]; }; struct peer {