torrentd

simple torrent daemon
git clone git://git.2f30.org/torrentd
Log | Files | Refs | LICENSE

commit 24b165fc21f693e6d252453a82f4db0c682c8d0b
parent c58661dfe92d768c48bdbbac424bf6eadc039ebc
Author: sin <sin@2f30.org>
Date:   Mon, 21 Dec 2015 17:41:50 +0000

don't use strnstr

Diffstat:
Mtracker.c | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tracker.c b/tracker.c @@ -31,12 +31,13 @@ tracker_get_peers(struct torrent *t, struct ben **reply) goto err0; writeall(s, buf, r); - r = readall(s, buf, sizeof(buf)); + r = readall(s, buf, sizeof(buf) - 1); + buf[r] = '\0'; - if ((p = strnstr(buf, "\r\n\r\n", r))) { + if ((p = strstr(buf, "\r\n\r\n"))) { p += 4; r -= 4; - } else if ((p = strnstr(buf, "\n\n", r))) { + } else if ((p = strstr(buf, "\n\n"))) { p += 2; r -= 2; } else {