[BitTorrent] Uninformative error handling on truncated torrents

Mike Ravkine krypt at mountaincable.net
Tue Sep 7 10:49:09 EDT 2004


Hello group,

    A user has recently e-mailed me a torrent complaining that it 
doesn't work in my client (burst core v1.1.3, based on BT 3.4.2).. after 
some analysis, I determined that the user had only downloaded the first 
15k or so of a 55k torrent file.  I propose the following change to 
bencode.py (I'd post a patch, but cvs.sourceforge.net is down right now 
for some reason):

def decode_string(x, f):
    ...
    colon += 1
    if n > (len(x)-colon):
    raise ValueError, "This torrent file appears to be incomplete.  
Please re-download it."   
    return (x[colon:colon+n], colon+n)

    Assuming I don't have any off-by-one errors (I didn't look to see 
why colon was increments), this detects when a string is shorter then 
it's supposed to be (as is commonly the case with the pieces string and 
a truncated torrent), and returns an informative error message to the user.

--kRYPT



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/dkFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/BitTorrent/

<*> To unsubscribe from this group, send an email to:
    BitTorrent-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the BitTorrent mailing list