perl_bulk_gets patch breaks some scripts

Bug #1806421 reported by Jean-Louis Dupond
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Net-SNMP
New
Unknown
net-snmp (Debian)
Fix Released
Unknown
net-snmp (Ubuntu)
Incomplete
Undecided
Unassigned

Bug Description

I upgraded from Ubuntu 16.04 to 18.04, and suddenly one of my perl snmp scripts (https://github.com/alaskacommunications/nagios_check_keepalived/blob/master/check_keepalived_vrrp.pl) started failing.
When switching back to SNMP v1 (which uses getnext instead of getbulk), it gives the following errors:
Use of uninitialized value $stopcond in quotemeta at /usr/lib/x86_64-linux-gnu/perl5/5.26/SNMP.pm line 884.
Use of uninitialized value $stopcond in quotemeta at /usr/lib/x86_64-linux-gnu/perl5/5.26/SNMP.pm line 884.
Use of uninitialized value $stopcond in quotemeta at /usr/lib/x86_64-linux-gnu/perl5/5.26/SNMP.pm line 884.
Use of uninitialized value $stopcond in quotemeta at /usr/lib/x86_64-linux-gnu/perl5/5.26/SNMP.pm line 884.
Use of uninitialized value $stopcond in quotemeta at /usr/lib/x86_64-linux-gnu/perl5/5.26/SNMP.pm line 884.

After digging in the changes between net-snmp in ubuntu 16.04 and 18.04, I found out the following patch is the cause of this:
    * fix_perl_bulk_gets.diff: Fix handling of truncated bulk get responses
      in the Perl module. (Patch 1278 in upstream patch tracker.)

When I reverted this, everything started to work fine again :)

I tried fixing the patch, and the following makes everything start working again, but still some undef warnings:

--- SNMP.pm.bak 2018-10-15 16:16:15.000000000 +0200
+++ SNMP.pm 2018-12-03 15:26:22.419130670 +0100
@@ -907,7 +907,7 @@
     my @newstopconds = ();
     my @newvarbinds = ();
     for (my $i = 0; $i < $num_stopconds; ++$i) {
- unless ($found_eof[$i]) {
+ unless ($found_eof[$i] || !defined($state->{'stopconds'}[$i])) {
         push @newstopconds, $state->{'stopconds'}[$i];
         push @newvarbinds, $state->{'varbinds'}[$i];
         }

So it seems like somebody with some more knowledge will need to have a look at this.

Thanks
Jean-Louis

Changed in netsnmp:
status: Unknown → New
Revision history for this message
Andreas Hasenack (ahasenack) wrote :
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

What is the failure you get when running https://github.com/alaskacommunications/nagios_check_keepalived/blob/master/check_keepalived_vrrp.pl on ubuntu bionic? You only showed the undef errors when switching to SNMPv1

Revision history for this message
Jean-Louis Dupond (dupondje) wrote :

Then I just get:
VRRP UNKNOWN: SNMP error: Unknown Object Identifier

It fails on
   $vit = $sess->gettable('KEEPALIVED-MIB::vrrpInstanceTable');

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in net-snmp (Ubuntu):
status: New → Confirmed
Revision history for this message
mzac (zachary-mcgibbon) wrote :

I just upgraded my Icinga server last night from 16.04 to 18.04 and I am also using the same script and I am having the same issue. I also posted an issue on the author's page as a heads up to see if they can update the script:

https://github.com/alaskacommunications/nagios_check_keepalived/issues/3

Revision history for this message
Danieljf1983 (danieljf1983) wrote :

Use of uninitialized value $stopcond in quotemeta at /usr/lib/x86_64-linux-gnu/perl5/5.30/SNMP.pm line 884, <CONF> line 252.
Use of uninitialized value $stopcond in quotemeta at /usr/lib/x86_64-linux-gnu/perl5/5.30/SNMP.pm line 884, <CONF> line 252.
Use of uninitialized value $stopcond in quotemeta at /usr/lib/x86_64-linux-gnu/perl5/5.30/SNMP.pm line 884, <CONF> line 252.
Use of uninitialized value $stopcond in quotemeta at /usr/lib/x86_64-linux-gnu/perl5/5.30/SNMP.pm line 884, <CONF> line 252.
Use of uninitialized value $stopcond in quotemeta at /usr/lib/x86_64-linux-gnu/perl5/5.30/SNMP.pm line 884, <CONF> line 252.

Revision history for this message
Danieljf1983 (danieljf1983) wrote :

Tested on standard debian buster, upped packages and issue persists

Revision history for this message
Danieljf1983 (danieljf1983) wrote :

My apologies - I accidentally put it on fix-released and not able to change it back to confirmed. Can somebody please update it?

Changed in net-snmp (Ubuntu):
status: Confirmed → Fix Released
Changed in net-snmp (Ubuntu):
status: Fix Released → Confirmed
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks for writing this bug report and help making Ubuntu better.

I'd like to take a step back here and ask a few questions regarding the bug description. The errors you mentioned seem to be related to the $stopcond variable that gets created on line 884, like this:

my $stopcond = $state->{'stopconds'}[$stopcond_num];

And $stopcond_num is defined as:

my $stopcond_num = $i % $num_stopconds;

However, your proposed solution is refers to the another section of that function. I'm trying to understand if there are other errors you may have seen but haven't posted here, maybe?

Could you please provide a bit more details on the warning/error messages you're seeing here? Also, a reproducer would be really helpful. I spent some time reading the code in question and I could not find how $state->{'stopconds'} can be undefined in this case.

Anyway, sorry for taking long to reply and let me know if you're still experiencing this problem.

Thanks in advance.

Changed in net-snmp (Ubuntu):
status: Confirmed → Incomplete
Changed in netsnmp:
status: New → Fix Released
Paride Legovini (paride)
Changed in netsnmp:
importance: Unknown → Undecided
status: Fix Released → New
importance: Undecided → Unknown
status: New → Unknown
Changed in net-snmp (Debian):
importance: Undecided → Unknown
status: New → Unknown
Revision history for this message
Paride Legovini (paride) wrote :

I adjusted the remote bug trackers a bit, note that the Debian bug is marked as Fix Released here on Launchpad but it should be considered marked Wontfix or Invalid, see [1].

As an Ubuntu bug, I think Sergio's comment and questions still stand, so I'm leaving it as Incomplete.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=915401#10

Changed in net-snmp (Debian):
status: Unknown → Fix Released
Changed in netsnmp:
status: Unknown → New
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.