Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.1

Bug #15453 $packed_hash issue (pack("H*", $val))
Submitted: 2008-12-30 03:22 UTC Modified: 2009-01-26 04:35 UTC
From: mattiasg Assigned: tacker
Status: Closed Package: File_Bittorrent2 (version 1.2.0)
PHP Version: 5.1.6 OS: CentOS 5.2 (final)
Roadmaps: (Not assigned)    

 [2008-12-30 03:22 UTC] mattiasg (Mattias Geniar)
Description: ------------ Sometimes there's a torrent that can't be decoded, and which throws a "Invalid Scrape Data"-error. I tried some debugging on my own, but having no prior knowledge of how BitTorrent encrypted files work, I didn't get that far. As far as debugging went, I tracked it down to what appears to be an invalid "$packed_hash" at line ~490, which messes up the array $stats['files']. Some torrents seem to have a weird result when pack()-ing. Scraping goes OK (seeders/leechers/downloaded are retrieved), but the class ends with a fatal error, due to that $packed_hash. Test script: --------------- The examples included in the package, to retrieve the torrent info, or the scrape-info, all show this error. It can be reproduced by loading the following torrent: Expected result: ---------------- File listing, seeders/leechers, announce list, filesize, ... Actual result: -------------- File_Bittorrent2_Exception::__set_state(array( 'cause' => NULL, '_trace' => NULL, 'message' => 'Invalid scrape data: \'d5:filesd20:g', 'string' => '', 'code' => 1, 'file' => '/usr/share/pear/File/Bittorrent2/Decode.php', 'line' => 503, 'trace' => array ( 0 => array ( 'file' => 'includes/functions.php', 'line' => 273, 'function' => 'getStats', 'class' => 'File_Bittorrent2_Decode', 'type' => '->', 'args' => array ( ), ),


 [2009-01-24 13:49 UTC] jonathandoe (Jonathan Doe)
This bug is also confirmed on PHP v 5.2.6.
 [2009-01-25 07:45 UTC] tacker (Markus Tacker)
I cannot reproduce this bug on PHP 5.2.8. Solution: Update your PHP version. This is what I get when decoding the torrent: I've added a test case for it. To run the test to verify the bug on your system after upgrading PHP please follow these steps: 1. Install PHPUnit [1] 2. check out File_Bittorrent from [2] 3. run the test 4. Post the output 5. Post the output of php --info e.g.: $ svn co [2] FileBittorrent2 $ cd FileBittorrent2 $ phpunit Tests_Bug15453 $ php --info [1] [2]
 [2009-01-25 14:48 UTC] mattiasg (Mattias Geniar)
Hi Markus, It seems I was a but unclear in my original bug report, the error doesn't occur when decoding the file, but when scraping the result returned by the tracker. In the scrape.php file provided by the Bittorrent2-package, the message is thrown by the following line: $File_Bittorrent2_Decode->getStats(); Error message: "Fatal error: Uncaught File_Bittorrent2_Exception: Invalid scrape data: 'd5:filesd20:g in .... ". I've run the PHPUnit testcase you provided on both PHP 5.2.6 and PHP 5.2.8 and both are completed without errors. On both installations, however, the getStats() returns a fatal error. I would guess this bug can be reproduced on any system, unless the flaw should be found in one of the side-packages PHP uses.
 [2009-01-26 04:35 UTC] tacker (Markus Tacker)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at