1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00
elinks/src/protocol/bittorrent
Kalle Olavi Niemitalo d93bceb9bd Fix blacklist crash in BitTorrent
make_bittorrent_peer_connection() used to construct a struct uri on
the stack. This was hacky but worked nicely because the struct uri
was not really accessed after make_connection() returned.  However,
since commit a83ff1f565, the struct uri
is also needed when the connection is being closed.  Valgrind shows:

Invalid read of size 2
   at 0x8100764: get_blacklist_entry (blacklist.c:33)
   by 0x8100985: del_blacklist_entry (blacklist.c:64)
   by 0x80DA579: complete_connect_socket (socket.c:448)
   by 0x80DA84A: connected (socket.c:513)
   by 0x80D0DDF: select_loop (select.c:297)
   by 0x80D00C6: main (main.c:353)
 Address 0xBEC3BFAE is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes

To fix this, allocate the struct uri on the heap instead, by
constructing a string and giving that to get_uri().  This string
cannot use the "bittorrent" URI scheme because parse_uri() does not
recognize the host and port fields in that.  (The "bittorrent" scheme
has protocol_backend.free_syntax = 1 in order to support strings like
"bittorrent:http://beta.legaltorrents.com/get/159-noisome-beasts".)
Instead, define a new "bittorrent-peer" URI scheme for this purpose.
If the user attempts to use this URI scheme, its handler aborts the
connection with an error; but when make_bittorrent_peer_connection()
uses a bittorrent-peer URI, the handler is not called.

This change also lets get_uri() set the ipv6 flag if peer_info->ip is
an IPv6 address literal.

Reported by Witold Filipczyk.
2008-09-07 06:31:36 +03:00
..
bencoding.c const in BitTorrent 2008-01-26 18:10:35 +02:00
bencoding.h Remove now useless $Id: lines. 2005-10-21 09:14:07 +02:00
bittorrent.c Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
bittorrent.h Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
common.c Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
common.h Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
connection.c Fix blacklist crash in BitTorrent 2008-09-07 06:31:36 +03:00
connection.h Fix blacklist crash in BitTorrent 2008-09-07 06:31:36 +03:00
dialogs.c Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
dialogs.h Remove now useless $Id: lines. 2005-10-21 09:14:07 +02:00
Makefile path_to_top -> top_builddir 2005-10-20 04:00:35 +02:00
peerconnect.c Fix blacklist crash in BitTorrent 2008-09-07 06:31:36 +03:00
peerconnect.h Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
peerwire.c Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
peerwire.h Remove now useless $Id: lines. 2005-10-21 09:14:07 +02:00
piececache.c bittorrent: Overflow occuring when a piece was rejected. 2008-03-25 22:35:06 +01:00
piececache.h Doxygenate main header files of src/protocol/bittorrent 2007-08-08 13:20:26 +02:00
README fonseca: We don't do that for other downloaded files, so why add bt links? 2005-12-09 19:25:06 -05:00
tracker.c Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
tracker.h Remove now useless $Id: lines. 2005-10-21 09:14:07 +02:00

The ELinks BitTorrent Client
============================

The BitTorrent client is fully usable and has been tested on multiple sites, it
does however still lack certain core functionally and is therefore marked
experimental. Below, various known problems and limitations are listed:

 - Peer IDs should be restorable from ~/.elinks/downloadhist.

 - It needs to give up on unreachable peers.

 - It should be possible to specify the download location.

 - When the file is removed from under it (in the shell), either give a warning
   and stop downloading, or start over.

 - Addition of a blacklist, either temporary (session) or persistant.

 - Unsupported Tracker Protocol Error: When connecting to some trackers we get
   a returned failure reason reading:

	unsupported tracker protocol, please upgrade your client

   often this is due to the compact peer format is not enabled. We should maybe
   try to reconnect when this occurs.

 - Multiple Trackers: The metainfo file can contain a list of tracker URIs so
   that the client can handle tracker request errors more gracefully by
   attempting to connect to a new tracker.  Although this functionality should
   be simple to add to the client we have chosen not to implement this.

 - Access to Disk: Currently, the are a couple of assertions in respect to disk
   access. Once pieces are completed they can never become incomplete again if
   something was to remove them from under the client.  This is a valid
   assertion for most systems and usage.  Furthermore, when writing and reading
   pieces, it is asserted that pieces are transferred correctly so that a read
   following a write will return the valid piece.

 - All access to disk uses blocking I/O. With the many consecutive reads and
   write the client uses, this can potential become a problem that can end up
   stalling all execution if the piece length is very big. For this reason, the
   ideas outlined in regard to a more fine grained solution using
   block-oriented disk access is even more relevant.

 - No download or upload rate limiting: All transferring happens
   unconditionally; in other words there are no means to limit the rate data is
   transferred. This can potential deny other services from running.

 - Badly configured web servers: We have experienced that many web servers
   providing metainfo files are badly configured in that they do not correctly
   set the content type. We have therefore found it necessary to also allow
   application/x-torrent in addition to application/x-bittorrent. However, some
   servers set the content type to text/plain which, due to the way ELinks
   prioritises content types provided in the protocol header sent by the
   server, means that loading many metainfo files will not cause the BitTorrent
   download to be queried. As a workaround, the internal BitTorrent URI scheme
   can be used. This, however, will not open the download dialog, but keep the
   download progress entirely in the status bar of the browser.

 - IPv6: Although certain informal extensions to the BitTorrent protocol, such
   as the compact peer information format returned by the tracker, are
   optimised for IPv4, the protocol works for IPv6.  We have only tested the
   client under IPv4.

 - Multiple Resumes: By default ELinks does three connection attempts.  This
   can cause the resuming to happen multiple times if the initial tracker
   connection causes the main BitTorrent connection to timeout.