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