torrentd

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

commit 9e388846ad8e90f8dd06e264fcf8a7e1ec20344f
parent 606d973333025a03cc3eab7933a62a94936cfdd0
Author: sin <sin@2f30.org>
Date:   Mon, 21 Dec 2015 22:18:48 +0000

nvm

Diffstat:
Mtracker.c | 17+++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/tracker.c b/tracker.c @@ -22,14 +22,11 @@ getpeers(struct torrent *t, struct ben **reply) "GET /%s?info_hash=%s&peer_id=%s&port=6881&uploaded=0&" "downloaded=0&left=%zu&event=started HTTP/1.1\r\n\r\n", path, infohash, id, t->totallen); - free(id); - free(infohash); - free(url); if (r < 0 || (size_t)r >= sizeof(buf)) - return -1; + goto fail; if ((s = dial(host, port)) < 0) - return -1; + goto fail; writeall(s, buf, r); r = readall(s, buf, sizeof(buf) - 1); @@ -46,7 +43,15 @@ getpeers(struct torrent *t, struct ben **reply) } if (!bdecode(p, p + r, reply)) - return -1; + goto fail; bprint(*reply, 0); + free(id); + free(infohash); + free(url); return 0; +fail: + free(id); + free(infohash); + free(url); + return -1; }