libeech

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

commit 4616e4a455bc12ababe1bf987375cdfb89327654
parent e7efd126cddc29317299860c1fbd2c8c783c6eda
Author: z3bra <contactatz3bradotorg>
Date:   Fri Jun 29 21:02:34 +0200

Remove unsused variable from pwprecv()

Diffstat:
libeech.c | 14++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/libeech.c b/libeech.c @@ -369,9 +369,10 @@ pwphsck(struct torrent *t, char *hs, long l) static ssize_t pwprecv(struct peer *p) { - ssize_t s, l, r; + ssize_t l, r; if (!p->rxbufsz) { + memset(p->rxbuf, 0, MSGSIZ); /* read the first 4 bytes to get message length */ if ((r = recv(p->fd, p->rxbuf, 4, MSG_PEEK)) < 4) return -1; @@ -380,19 +381,16 @@ pwprecv(struct peer *p) /* expected message length */ l = U32(p->rxbuf) + 4; - if (l > MSGSIZ) + if (l > MSGSIZ || l < 5) return -1; - s = p->rxbufsz; - while ((r = recv(p->fd, p->rxbuf, l - s, 0)) > 0) { - l -= r; - s += r; - } + while ((r = recv(p->fd, p->rxbuf, l - p->rxbufsz, 0)) > 0) + p->rxbufsz += r; if (r < 0) return -1; - return l; + return l - p->rxbufsz; } /*