RE: The Perl module (SNMP::), of which my module SNMP::Info depends. 

Hi Coders,

A user found a bug recently in SNMP.pm

In the subs {get,set,fget,getnext,fgetnext,getbulk,bulkwalk} there is a
regular expression that splits an OID from an iid.  Code looks like this :

    # my ($tag, $iid) = ($vars =~ /^((?:\.\d+)+|(?:\w+(?:\-*\w+)+))\.?(.*)$/);
      my ($tag, $iid) = ($vars =~ /^(.*?)\.?(\d+)+$/);

Everywhere it is referenced, the more complex regular expression is
commented out and the simpler one is used.   I assume that the above one had
a buggy case and was replaced for good reason. 

For a set operation, let's say I try to do a:

    portName.9.30 = 'test'

(snmpset -v2c -c community_rw NODE_IP s portName.9.30 Test)

The above regex matches $tag = "portName.9" and $iid = "30", 
and I get the error "Sub-id not found: (top) -> portName".

The commented out regex seems to work fine. 

I broke down the old regex so that it could be more maintainable :

my ($tag, $iid) = 
    ($vars =~ /^(               # Capture $1
                # 1. either this 5.5.5.5
                 (?:\.\d+)+     # for grouping, won't increment $1
                |
                # 2. or asdf-asdf-asdf-asdf
                 (?:            # grouping again
                    \w+         # needs some letters followed by
                    (?:\-*\w+)+ #  zero or more dashes, one or more letters
                 )
                )
                \.?             # optionally match a dot
                (.*)            # whatever is left in the string is our iid
               $/x
    );

Anyone remember what about this failed?

Since it's used all over the place, we could keep it in a separate sub, and
then just call it ... that might it easier to maintain.

sub _split_vars {
    my $self = shift;
    my $vars = shift;

    ... above code ...

    return \($tag,$iid);
}


Thanks,
-m


-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
Net-snmp-coders mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to