mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Fix crashes with various bogus BitTorrent URLs
... mainly bittorrent:// and bittorrent://x
The BitTorrent URL is supposed to contain an embedded URL pointing to a
metainfo file. If this is not the case a "custom" error message will be
shown. Also fixes calling of free_list() on an uninitialized list.
Closes bug 729.
[ From commit b61d8d06d9
in ELinks
0.12.GIT. This introduces a new string that perhaps won't be
translated in time for 0.11.3, but I think it's better to display
an error message in the wrong language than crash. --KON ]
This commit is contained in:
parent
c148be45ac
commit
69740ca021
@ -122,6 +122,7 @@ struct s_msg_dsc {
|
|||||||
{S_BITTORRENT_ERROR, N_("BitTorrent error")},
|
{S_BITTORRENT_ERROR, N_("BitTorrent error")},
|
||||||
{S_BITTORRENT_METAINFO, N_("The BitTorrent metainfo file contained errors")},
|
{S_BITTORRENT_METAINFO, N_("The BitTorrent metainfo file contained errors")},
|
||||||
{S_BITTORRENT_TRACKER, N_("The tracker requesting failed")},
|
{S_BITTORRENT_TRACKER, N_("The tracker requesting failed")},
|
||||||
|
{S_BITTORRENT_BAD_URL, N_("The BitTorrent URL does not point to a valid URL")},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{0, NULL}
|
{0, NULL}
|
||||||
|
@ -104,6 +104,7 @@ enum connection_state {
|
|||||||
S_BITTORRENT_ERROR = -100800,
|
S_BITTORRENT_ERROR = -100800,
|
||||||
S_BITTORRENT_METAINFO = -100801,
|
S_BITTORRENT_METAINFO = -100801,
|
||||||
S_BITTORRENT_TRACKER = -100802,
|
S_BITTORRENT_TRACKER = -100802,
|
||||||
|
S_BITTORRENT_BAD_URL = -100803,
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned char *get_state_message(enum connection_state state, struct terminal *term);
|
unsigned char *get_state_message(enum connection_state state, struct terminal *term);
|
||||||
|
@ -290,6 +290,10 @@ init_bittorrent_connection(struct connection *conn)
|
|||||||
bittorrent->conn = conn;
|
bittorrent->conn = conn;
|
||||||
bittorrent->tracker.timer = TIMER_ID_UNDEF;
|
bittorrent->tracker.timer = TIMER_ID_UNDEF;
|
||||||
|
|
||||||
|
/* Initialize here so that error handling can safely call
|
||||||
|
* free_list on it. */
|
||||||
|
init_list(bittorrent->meta.files);
|
||||||
|
|
||||||
return bittorrent;
|
return bittorrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +387,7 @@ bittorrent_metainfo_callback(void *data, enum connection_state state,
|
|||||||
void
|
void
|
||||||
bittorrent_protocol_handler(struct connection *conn)
|
bittorrent_protocol_handler(struct connection *conn)
|
||||||
{
|
{
|
||||||
struct uri *uri;
|
struct uri *uri = NULL;
|
||||||
struct bittorrent_connection *bittorrent;
|
struct bittorrent_connection *bittorrent;
|
||||||
|
|
||||||
bittorrent = init_bittorrent_connection(conn);
|
bittorrent = init_bittorrent_connection(conn);
|
||||||
@ -392,11 +396,11 @@ bittorrent_protocol_handler(struct connection *conn)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(conn->uri->datalen);
|
if (conn->uri->datalen)
|
||||||
|
uri = get_uri(conn->uri->data, 0);
|
||||||
|
|
||||||
uri = get_uri(conn->uri->data, 0);
|
|
||||||
if (!uri) {
|
if (!uri) {
|
||||||
abort_connection(conn, S_OUT_OF_MEM);
|
abort_connection(conn, S_BITTORRENT_BAD_URL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user