Skip Menu |

This queue is for tickets about the Convert-Bencode CPAN distribution.

Report information
The Basics
Id: 62550
Status: open
Priority: 0/
Queue: Convert-Bencode

People
Owner: Nobody in particular
Requestors: aleksandar [...] itcentar.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Bad error handling
Date: Fri, 29 Oct 2010 12:05:53 +0200
To: bug-Convert-Bencode [...] rt.cpan.org
From: "Aleksandar Stojilkovic - IT centar d.o.o." <aleksandar [...] itcentar.net>
Hello, I know that this isn't a bug but more a bad error handling. I use your package in my scripts and found it very useful. But in case script receive bad encoded string, which is not so usual but it happen every few days beacuse my script query thousends of trackers for torrent health, your script go in some kind of infinite loop. To resove this, i had to either edit your code or to use other package which is pity. Is there some kind of workaround for this? I use: Convert-Bencode-1.03 Summary of my perl5 (revision 5 version 10 subversion 1) configuration: Platform: osname=MSWin32, osvers=5.00, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef This code will create loop: #!/usr/bin/perl use strict; use warnings; use feature ':5.10'; use Convert::Bencode qw(bencode bdecode); my $string = "d5:filesed5:flagsd20:min_request_intervali1800eee"; my $hashref = bdecode($string); foreach my $key (keys(%{$hashref})) { print "Key: $key, Value: ${$hashref}{$key}\n"; } my $encoded_string = bencode($hashref); print $encoded_string."\n"; Regards, Aleksandar
Hi, I think I solved this problem by adding a loop termination when the chunks array is empty. My code is forked from the gitpan repo, and is available at: https://github.com/m4ddav3/Convert-Bencode Orclev: I would be happy to do a release into CPAN if you like. Cheers, David On Fri Oct 29 06:06:22 2010, aleksandar@itcentar.net wrote: Show quoted text
> Hello, > > I know that this isn't a bug but more a bad error handling. > > I use your package in my scripts and found it very useful. But in case > script receive bad encoded string, which is not so usual but it happen > every few days beacuse my script query thousends of trackers for torrent > health, your script go in some kind of infinite loop. > > To resove this, i had to either edit your code or to use other package > which is pity. > > Is there some kind of workaround for this? > > I use: > Convert-Bencode-1.03 > > Summary of my perl5 (revision 5 version 10 subversion 1) configuration: > > Platform: > osname=MSWin32, osvers=5.00, archname=MSWin32-x86-multi-thread > uname='' > config_args='undef' > hint=recommended, useposix=true, d_sigaction=undef > useithreads=define, usemultiplicity=define > useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef > use64bitint=undef, use64bitall=undef, uselongdouble=undef > usemymalloc=n, bincompat5005=undef > > > This code will create loop: > #!/usr/bin/perl > use strict; > use warnings; > use feature ':5.10'; > use Convert::Bencode qw(bencode bdecode); > > my $string = "d5:filesed5:flagsd20:min_request_intervali1800eee"; > my $hashref = bdecode($string); > > foreach my $key (keys(%{$hashref})) { > print "Key: $key, Value: ${$hashref}{$key}\n"; > } > > my $encoded_string = bencode($hashref); > print $encoded_string."\n"; > > > Regards, > Aleksandar