tFix HAVE message format - libeech - bittorrent library
 (HTM) git clone git://z3bra.org/libeech.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit f7370a56387cdf870b62b309db021c9c4f2ae9bd
 (DIR) parent 207bde90ffe79608f7ac5c69117bb379a9648903
 (HTM) Author: z3bra <contactatz3bradotorg>
       Date:   Wed,  4 Jul 2018 19:36:01 +0200
       
       Fix HAVE message format
       
       Diffstat:
         M libeech.c                           |       8 ++++----
       
       1 file changed, 4 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/libeech.c b/libeech.c
       t@@ -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;
       t@@ -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;
       t@@ -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);