libeech

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

commit f7370a56387cdf870b62b309db021c9c4f2ae9bd
parent 207bde90ffe79608f7ac5c69117bb379a9648903
Author: z3bra <contactatz3bradotorg>
Date:   Wed Jul  4 19:36:01 +0200

Fix HAVE message format

Diffstat:
libeech.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libeech.c b/libeech.c @@ -324,7 +324,7 @@ addpeer(struct peer *pl, char *host, int port) p->rxbufsz = 0; p->piece.n = -1; memcpy(p->host, host, HOST_NAME_MAX); - memset(p->bf, 0, PCENUM / 8); + memset(p->bf, 0, PCENUM / 8 + !!(PCENUM % 8)); memset(p->rxbuf, 0, MSGSIZ); return p; @@ -481,10 +481,10 @@ pwptxhv(struct peer *p, long n) { char m[MSGSIZ]; - memset(m, 0, 9); + memset(m, 0, 5); /* Message length */ - U32(m) = htonl(9); + U32(m) = htonl(5); /* Message type */ m[4] = HAVE; @@ -501,7 +501,7 @@ pwptxbf(struct torrent *t, struct peer *p) char m[MSGSIZ]; ssize_t l; - l = t->npiece / 8 + 1; + l = t->npiece / 8 + !!(t->npiece % 8); memset(m, 0, l + 5);