>>>>> On Wed, 8 Mar 2006 13:56:14 +0200, "Makavy, Erez (Erez)" <[EMAIL 
>>>>> PROTECTED]> said:

Erez> It looks like the ASN_PRIV_IMPLIED_OCTET_STR switch case, assumes that
Erez> the rest of the instance is the fixed length string (and it does not
Erez> look for a preceeding string length component).

Erez> But what if the instance includes some other index type after this
Erez> fix-length string?

If you set var->val_len as well it'll assume that this is the length
of the data you want to pull out.  That should just remove a fixed
size of data.
 
Erez> By the way:
Erez> -----------------
Erez> I saw something that looks like a bug:
Erez> In the parse_one_oid_index() function (Net-SNMP 5.3.0.1):

Erez> *********************************************
Erez> if (uitmp > (int) (*oidLen)) {
Erez> for (i = 0; i < *oidLen; ++i)
var-> val.string[i] = (u_char) * oidIndex++;
Erez> for (i = 0; i < uitmp; ++i)                 // Erez
Erez> Makavy: Is this a BUG?!!!
var-> val.string[i] = '\0';

Yep.  That's indeed a bug.  The patch is actually this:

Index: mib.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/snmplib/mib.c,v
retrieving revision 5.94
diff -u -p -r5.94 mib.c
--- mib.c       2 Feb 2006 22:08:39 -0000       5.94
+++ mib.c       8 Mar 2006 14:48:12 -0000
@@ -3799,7 +3799,7 @@ parse_one_oid_index(oid ** oidStart, siz
             if (uitmp > (int) (*oidLen)) {
                 for (i = 0; i < *oidLen; ++i)
                     var->val.string[i] = (u_char) * oidIndex++;
-                for (i = 0; i < uitmp; ++i)
+                for (i = *oidLen; i < uitmp; ++i)
                     var->val.string[i] = '\0';
                 (*oidLen) = 0;
             } else {

Erez> In this if cluase, the first 'for' startement is overridden by the
Erez> second 'for' statement.
Erez> (val.string, will always be set to all zeros)

Note that the only time this will ever be hit is if the string length
was supposed to be longer than the data encoded in the OID.  This
should actually never ever happen (IE, the OID is too short in the
first place for the expected data).

I've fixed it anyway because we like to handle exceptions...

-- 
Wes Hardaker
Sparta, Inc.


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to