Skip Menu |

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

Report information
The Basics
Id: 102337
Status: resolved
Priority: 0/
Queue: Net-SNMPTrapd

People
Owner: Nobody in particular
Requestors: jonathan.wilson [...] vanderbilt.edu
Cc:
AdminCc:

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



Subject: bug with v0.13
Date: Tue, 24 Feb 2015 21:49:07 +0000
To: "bug-Net-SNMPTrapd [...] rt.cpan.org" <bug-Net-SNMPTrapd [...] rt.cpan.org>
From: "Wilson, Jonathan" <jonathan.wilson [...] Vanderbilt.Edu>
Hello, I encountered an uninitialized variable condition in SNMPTrapd.pm version 0.13, line 384 - it appears that the "version" method is being called before the version attribute has been set. This was seen on a CentOS 5 64bit system with 64bit Perl 5.20.1, compiled from source. It results in warnings of the following form: Use of uninitialized value in addition (+) at /usr/local/lib/perl5/site_perl/5.20.1/Net/SNMPTrapd.pm line 384. I have attached a minimal program that demonstrates the issue, the output from "perl -V" and a one-line patch that fixes the problem. Regards, Jon Wilson Jon Wilson | Sr. System Engineer | IT Service Management | Information Technology | Vanderbilt University jonathan.wilson@vanderbilt.edu | phone 615.440-7895 | it.vanderbilt.edu<http://it.vanderbilt.edu/>
Download SNMPTrapd_bug.zip
application/x-zip-compressed 2k

Message body not shown because it is not plain text.

You're not using it correctly. The POD states that get_trap() allows only remoteaddr() remoteport() datagram() to be called. You need to call process_trap() to get access to: version() ... You're calling version() without first having called process_trap(), so there will be no value in the function. Try calling any accessor - community(), pdu_type() - they all will return undef until process_trap() is called. Taking your demonstration.pl script and adding: --- demonstration.pl 2015-02-24 15:42:24.000000000 -0500 +++ demonstration-new.pl 2015-02-24 17:11:24.524869300 -0500 @@ -19,6 +19,9 @@ next; } + $trap->process_trap(); + print $trap->version . "\n"; + my $real_version = ($trap->version == 0) ? '1' : '2c'; my $hex_trap_dump = $trap->datagram(1); } Fixes the issue. Cheers.
Subject: RE: [rt.cpan.org #102337] bug with v0.13
Date: Tue, 24 Feb 2015 22:21:43 +0000
To: "bug-Net-SNMPTrapd [...] rt.cpan.org" <bug-Net-SNMPTrapd [...] rt.cpan.org>
From: "Wilson, Jonathan" <jonathan.wilson [...] Vanderbilt.Edu>
Thank you, Michael. I hadn't caught that. Regards, Jon Wilson Jon Wilson | Sr. System Engineer | IT Service Management | Information Technology | Vanderbilt University jonathan.wilson@vanderbilt.edu | phone 615.440-7895 | it.vanderbilt.edu Show quoted text
-----Original Message----- From: Michael Vincent via RT [mailto:bug-Net-SNMPTrapd@rt.cpan.org] Sent: Tuesday, February 24, 2015 4:19 PM To: Wilson, Jonathan Subject: [rt.cpan.org #102337] bug with v0.13 <URL: https://rt.cpan.org/Ticket/Display.html?id=102337 > You're not using it correctly. The POD states that get_trap() allows only remoteaddr() remoteport() datagram() to be called. You need to call process_trap() to get access to: version() ... You're calling version() without first having called process_trap(), so there will be no value in the function. Try calling any accessor - community(), pdu_type() - they all will return undef until process_trap() is called. Taking your demonstration.pl script and adding: --- demonstration.pl 2015-02-24 15:42:24.000000000 -0500 +++ demonstration-new.pl 2015-02-24 17:11:24.524869300 -0500 @@ -19,6 +19,9 @@ next; } + $trap->process_trap(); + print $trap->version . "\n"; + my $real_version = ($trap->version == 0) ? '1' : '2c'; my $hex_trap_dump = $trap->datagram(1); } Fixes the issue. Cheers.