From 45669fed089a4ea4e38c4d5efabc6e27c881b490 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Thu, 5 May 2011 03:10:51 +0000 Subject: [PATCH] (trunk libT) #4227 "invalid URLs aren't filtered out of .torrents' webseed lists" If we can't parse a URL provided in the .torrent files' webseed list, that URL should be discarded. --- libtransmission/metainfo.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/libtransmission/metainfo.c b/libtransmission/metainfo.c index f76122ce4..7cc168126 100644 --- a/libtransmission/metainfo.c +++ b/libtransmission/metainfo.c @@ -370,14 +370,26 @@ geturllist( tr_info * inf, inf->webseeds = tr_new0( char*, n ); for( i = 0; i < n; ++i ) + { if( tr_bencGetStr( tr_bencListChild( urls, i ), &url ) ) - inf->webseeds[inf->webseedCount++] = tr_strdup( url ); + { + const size_t len = strlen( url ); + + if( tr_urlIsValid( url, len ) ) + inf->webseeds[inf->webseedCount++] = tr_strndup( url, len ); + } + } } else if( tr_bencDictFindStr( meta, "url-list", &url ) ) /* handle single items in webseeds */ { - inf->webseedCount = 1; - inf->webseeds = tr_new0( char*, 1 ); - inf->webseeds[0] = tr_strdup( url ); + const size_t len = strlen( url ); + + if( tr_urlIsValid( url, len ) ) + { + inf->webseedCount = 1; + inf->webseeds = tr_new0( char*, 1 ); + inf->webseeds[0] = tr_strndup( url, len ); + } } }