Subject: | _syminfo_from_syminfo_siblings wrongly compares packed value length to value limits |
Date: | Mon, 28 Jan 2013 20:38:23 +0100 |
To: | bug-DOCSIS-ConfigFile [...] rt.cpan.org |
From: | Dušan Dragić <dragic.dusan [...] gmail.com> |
I just started testing DOCSIS::ConfigFile and got hit by this while
encoding a sample config:
Invalid value for DownstreamFrequency: 0/1: 4 < 88000000 at
/usr/local/share/perl5/DOCSIS/ConfigFile.pm line 440
DOCSIS::ConfigFile::_syminfo_from_syminfo_siblings('DOCSIS::ConfigFile=HASH(0x930b48)',
'DOCSIS::ConfigFile::Syminfo=HASH(0xf06270)', 'SCALAR(0x1223378)')
called at /usr/local/share/perl5/DOCSIS/ConfigFile.pm line 399
DOCSIS::ConfigFile::_encode_loop('DOCSIS::ConfigFile=HASH(0x930b48)',
'ARRAY(0x94ef20)') called at
/usr/local/share/perl5/DOCSIS/ConfigFile.pm line 331
DOCSIS::ConfigFile::encode('DOCSIS::ConfigFile=HASH(0x930b48)',
'ARRAY(0x94ef20)') called at ./docsis_conf_test.pl line 21
In this case the value for DownstreamFrequency was 682000000, but it
doesn't matter what the value is.
After a quick glance at _syminfo_from_syminfo_siblings, it looks like
it is taking the length of the packed bytes
and testing it against the low/high value limits that are defined in
the symtable, which doesn't seem right.
It should be comparing the requested value itself (not length of the
representation of that value) to the limits.
As can be seen from the error the length is 4 (bytes), since
DownstreamFrequency is uint, and the low value limit
is 88000000 (as defined in the symtable). It is clear that the test
will always fail.
Of course, changing the low limit for DownstreamFrequency (in
Syminfo.pm) from 88000000 to a number lower then 4
will let the program complete successfully, but that isn't a proper fix.
This doesn't seem to affect other TLVs since their length (in bytes)
is bigger then their defined low limit.
Besides this problem, everything works as expected. That is, if I
remove DownstreamFrequency TLV
it finishes encoding successfully. Also, decoding works just fine.
English isn't my first language so I apologize if I'm not being clear enough.
System info:
DOCSIS-ConfigFile-0.63, perl v5.14.3, Fedora 16 x86-64.