Skip Menu |

This queue is for tickets about the Net-SNMP CPAN distribution.

Report information
The Basics
Id: 42464
Status: rejected
Worked: 10 min
Priority: 0/
Queue: Net-SNMP

People
Owner: dtown [...] cpan.org
Requestors: frimik [...] gmail.com
Cc:
AdminCc:

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



Subject: Invalid IpAddress length (8 bytes) against 64bit net-snmpd
Example: performing a get_request for oid: .1.3.6.1.2.1.4.21.1.7.0.0.0.0 will result in an error if performed against a net-snmpd server <4.0: "request error: Invalid IpAddress length (8 bytes)" net-snmp versions <5.4 have a bug where IpAddress is 8 bytes instead of 4 on 64bit hosts: http://www.net-snmp.org/about/ChangeLog.html - 5.4: snmpd: - fix 8 byte IpAddress in at, ip and route MIBs. So, what I did was patch Net::SNMP so it works against both good and "bad" 64bit net-snmp servers. A patch is attached which works around the issue.
Subject: libnet-snmp-perl-8byte.patch
--- Message.pm.dpkg-orig 2009-01-16 13:04:28.627374174 +0100 +++ Message.pm 2009-01-16 13:07:39.412626749 +0100 @@ -1456,15 +1456,15 @@ # Decode the length return $this->_error unless defined(my $length = $this->_process_length); - - if ($length != 4) { + # snmpd <4.0 has an 8 byte IpAddress on 64bit systems //Fridh + if ($length != 4 && $length != 8) { return $this->_error( 'Invalid IpAddress length (%d byte%s)', $length, ($length != 1 ? 's' : '') ); } - if (defined(my $ip = $this->_buffer_get(4))) { + if (defined(my $ip = $this->_buffer_get($length))) { sprintf('%vd', $ip); } else { $this->_error;
Subject: previous patch botched
Previous patch returns an address padded with zeroes. This one seems to work properly
--- Message.pm.dpkg-orig 2009-01-16 13:04:28.627374174 +0100 +++ Message.pm 2009-01-16 15:40:09.853468328 +0100 @@ -298,6 +298,7 @@ return $_[0]->_error unless defined(my $type = $_[0]->_buffer_get(1)); $type = unpack('C', $type); + print($type, "\n"); if (exists($process_methods->{$type})) { if ((@_ >= 2) && (defined($_[1])) && ($type != $_[1])) { @@ -1456,16 +1457,16 @@ # Decode the length return $this->_error unless defined(my $length = $this->_process_length); - - if ($length != 4) { + # snmpd <4.0 has an 8 byte IpAddress on 64bit systems //Fridh + if ($length != 4 && $length != 8) { return $this->_error( 'Invalid IpAddress length (%d byte%s)', $length, ($length != 1 ? 's' : '') ); } - if (defined(my $ip = $this->_buffer_get(4))) { - sprintf('%vd', $ip); + if (defined(my $ip = $this->_buffer_get($length))) { + sprintf('%vd', substr($ip, 0, 4)); } else { $this->_error; }
proper patch this time without annoying debug output in Message.pm.
--- Message.pm.dpkg-orig 2009-01-16 13:04:28.627374174 +0100 +++ Message.pm 2009-01-16 15:46:18.953589664 +0100 @@ -1457,15 +1457,15 @@ # Decode the length return $this->_error unless defined(my $length = $this->_process_length); - if ($length != 4) { + if ($length != 4 && $length != 8) { return $this->_error( 'Invalid IpAddress length (%d byte%s)', $length, ($length != 1 ? 's' : '') ); } - if (defined(my $ip = $this->_buffer_get(4))) { - sprintf('%vd', $ip); + if (defined(my $ip = $this->_buffer_get($length))) { + sprintf('%vd', substr($ip, 0, 4)); } else { $this->_error; }
Thank you for your suggested patch for Net::SNMP. The Net::SNMP module has been run through a conformance test in which negative (malformed) messages are are part of the test. Adding this work around would cause a failure in the test. I also try to minimize deviating from the standards to avoid code bloat resulting from accommodating incorrect SNMP implementations.