tFix off-by-one error with when passing payload to pwprxcb() - libeech - bittorrent library
 (HTM) git clone git://z3bra.org/libeech.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 774c0676d1298d2731342468f3f53c0f4e5a9630
 (DIR) parent f7370a56387cdf870b62b309db021c9c4f2ae9bd
 (HTM) Author: z3bra <contactatz3bradotorg>
       Date:   Thu,  5 Jul 2018 08:14:06 +0200
       
       Fix off-by-one error with when passing payload to pwprxcb()
       
       Diffstat:
         M libeech.c                           |       8 ++++----
       
       1 file changed, 4 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/libeech.c b/libeech.c
       t@@ -611,9 +611,9 @@ pwprxpc(struct torrent *t, struct peer *p, size_t sz, char *pl)
                char *blk;
                struct peer *b;
        
       -        idx = ntohl(U32(pl+1));
       -        off = ntohl(U32(pl+5));
       -        blk = pl + 9;
       +        idx = ntohl(U32(pl));
       +        off = ntohl(U32(pl+4));
       +        blk = pl + 8;
        
                memcpy(p->piece.blks + off, blk, sz - 8);
        
       t@@ -688,7 +688,7 @@ pwprx(struct torrent *t, struct peer *p)
                        p->rxbufsz = 0;
                        p->state |= HANDSHAKERCVD;
                } else if (!pwprecv(p)) {
       -                pwprxcb(t, p, p->rxbuf[4], p->rxbufsz - 5, p->rxbuf+4);
       +                pwprxcb(t, p, p->rxbuf[4], p->rxbufsz - 5, p->rxbuf+5);
                        memset(p->rxbuf, 0, MSGSIZ);
                        p->rxbufsz = 0;
                }