Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DOCSIS-ConfigFile CPAN distribution.

Report information
The Basics
Id: 34547
Status: resolved
Priority: 0/
Queue: DOCSIS-ConfigFile

People
Owner: Nobody in particular
Requestors: dmircea [...] gmail.com
Cc:
AdminCc:

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



Subject: MfgCVCData
When the config file contains the MfgCVCData the decode succeeds but encoding it back pops out an error. Please see attached the dec_enc.pl script used to decode and encode back the same content. When running I hit the following errors: % ./dec_enc.pl rt_bugs_sample.bin Integer overflow in hexadecimal number at /usr/lib/perl5/site_perl/5.8.8/DOCSIS/ConfigFile.pm line 295. Hexadecimal number > 0xffffffff non-portable at /usr/lib/perl5/site_perl/5.8.8/DOCSIS/ConfigFile.pm line 295. ERROR - Value too high: MfgCVCData=inf Integer overflow in hexadecimal number at /usr/lib/perl5/site_perl/5.8.8/DOCSIS/ConfigFile.pm line 295. Hexadecimal number > 0xffffffff non-portable at /usr/lib/perl5/site_perl/5.8.8/DOCSIS/ConfigFile.pm line 295. ERROR - Value too high: MfgCVCData=inf Integer overflow in hexadecimal number at /usr/lib/perl5/site_perl/5.8.8/DOCSIS/ConfigFile.pm line 295. Hexadecimal number > 0xffffffff non-portable at /usr/lib/perl5/site_perl/5.8.8/DOCSIS/ConfigFile.pm line 295. ERROR - Value too high: MfgCVCData=inf Integer overflow in hexadecimal number at /usr/lib/perl5/site_perl/5.8.8/DOCSIS/ConfigFile.pm line 295. Hexadecimal number > 0xffffffff non-portable at /usr/lib/perl5/site_perl/5.8.8/DOCSIS/ConfigFile.pm line 295. ERROR - Value too high: MfgCVCData=inf ERROR - Value too high: RequestOrTxPolicy=00000060 ERROR - Value too low: IpTosOverwrite=0000 I was happy to see that this perl module came out. I was looking for it since a long time ago. Congratulation! % perl -v This is perl, v5.8.8 built for i386-linux-thread-multi Copyright 1987-2006, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page
Subject: rt_bugs_sample.bin
Download rt_bugs_sample.bin
application/unknown 6.6k

Message body not shown because it is not plain text.

Subject: dec_enc.pl
#!/usr/bin/perl -w use DOCSIS::ConfigFile; use Data::Dumper; if($#ARGV ne 0) { print "Missing file argument!\n"; exit(1); } my $filename=$ARGV[0]; my $outfile=$filename.".out"; die if(!open(OUT, "> $outfile")); my $obj = DOCSIS::ConfigFile->new( shared_secret => 'foobar', advanced_output => 1, ); my $decoded = $obj->decode($filename); my $encoded=$obj->encode($decoded); print OUT $encoded; close(OUT); exit(0);
From: dmircea [...] gmail.com
Patch attached.
--- ./ConfigFile/Encode.pm.orig 2008-04-01 09:51:54.000000000 +0300 +++ ./ConfigFile/Encode.pm 2008-04-02 09:42:34.000000000 +0300 @@ -188,7 +188,9 @@ for my $tlv (@$nested) { push @bytes, $tlv->{'type'}; push @bytes, $tlv->{'length'}; - push @bytes, $tlv->{'value'}; + for(my $i=0; $i<$tlv->{'length'}; $i++) { + push @bytes, $tlv->{'value'}[$i]; + } } ### the end @@ -241,18 +243,28 @@ sub hexstr { #================================================================ + ### init my $ether = shift()->{'value'}; ### numeric - if($ether =~ /^\d+$/) { - return int_to_bytes({ value => $ether }); + if($ether =~ /^(?:0x)?[0-9a-f]+$/i) { + return hex_to_bytes({ value => $ether }); } +} - ### hex - elsif($ether =~ /^(?:0x)?[0-9a-f]+$/i) { - return int_to_bytes({ value => hex($ether) }); +sub hex_to_bytes { #========================================================== + + ### init + my $string = shift()->{'value'}; + my @bytes; + + foreach my $byte ($string =~ /(..)/g) { + push @bytes, hex($byte); } + + ### the end + return @bytes; } sub int_to_bytes { #========================================================== --- ./ConfigFile/Decode.pm.orig 2008-04-01 14:14:09.000000000 +0300 +++ ./ConfigFile/Decode.pm 2008-04-02 09:40:45.000000000 +0300 @@ -177,11 +177,11 @@ while(@data) { my $type = shift @data; my $length = shift @data; - my $value = splice @data, 0, $length; + my @value = splice @data, 0, $length; push @ret, { type => $type, length => $length, - value => $value, + value => [@value], }; } --- ./ConfigFile.pm.orig 2008-03-29 09:56:24.000000000 +0200 +++ ./ConfigFile.pm 2008-04-02 10:04:52.000000000 +0300 @@ -258,8 +258,10 @@ for my $tlv (@$config) { ### init - my $name = $tlv->{'name'} or next TLV; - my $syminfo = DOCSIS::ConfigFile::Syminfo->from_id($name); + my $name = $tlv->{'name'} or next TLV; + next TLV if($name eq "NA"); + + my $syminfo = DOCSIS::ConfigFile::Syminfo->from_id($name); my $sub = DOCSIS::ConfigFile::Encode->can($syminfo->func); my $code = $syminfo->code; @@ -288,19 +290,30 @@ next TLV; } + + my $val; + ### check value range - if($syminfo->l_limit or $syminfo->u_limit) { - my $value = ($tlv->{'value'} =~ /\D/) ? hex $tlv->{'value'} - : $tlv->{'value'}; - if($value > $syminfo->u_limit) { - $self->log->error("Value too high: $name=$value"); + if($syminfo->l_limit or $syminfo->u_limit) { + if($syminfo->func eq "hexstr") { + $val = length($tlv->{'value'})/2; + } + else { + $val = ($tlv->{'value'} =~ /\D/) ? hex $tlv->{'value'} : $tlv->{'value'}; + } + } + + if(defined($val)) { + if($val > $syminfo->u_limit) { + $self->log->error("Value too high: $name=$val"); next TLV; } - if($value < $syminfo->l_limit) { - $self->log->error("Value too low: $name=$value"); + if($val < $syminfo->l_limit) { + $self->log->error("Value too low: $name=$val"); next TLV; } - } + } + ### set type, length and value my @value = $sub->($tlv);
Fixed in 0.5. The issue was in general related to trying to convert values higher than 2^32.