On Tue, Sep 19, 2006 at 07:05:49PM +0100, Dave Shield wrote:
> On 19/09/06, Dave Shield <[EMAIL PROTECTED]> wrote:
> > I don't think it's the HAL code - it appears to be a deficiency in the
> > scalar_group helper (or possibly the higher-level MIB registry
> > handling).
> 
> Confirmed.
> The "find_prefix" routine (in snmplib/snmp_api.c) wasn't handling the
> case where one OID was a strict prefix of the other.  It returned 0,
> rather than the length of the common prefix.   Fixing this allowed the
> original memory code to work correctly.
> 
> I'm also not convinced that the value returned by this routine is correct.
> It seems to report the (1-based) index of the first *mis-match* in the OIDs,
> rather than the length of the common prefix (as documented).
>    AFAICT, the return value is never actually used as such - just
> compared to see whether there was a match.  So it ought to be safe to
> correct this.
> But I haven't checked the code carefully, so this may be wrong.
> 
> Comments?

Is find_prefix part of the public API? If that is the case then the question
is what any external users might expect of it.

Now that I have said the above I agree that always returning the length of the
common prefix do sound like a more useful function.

Looking around in snmp_api.c it looks as if there are quite a few ways to
compare two OID's - we have

snmp_oid_ncompare
snmp_oid_compare
netsnmp_oid_compare_ll
snmp_oidtree_compare
netsnmp_oid_equals
netsnmp_oid_is_subtree
netsnmp_oid_find_prefix

Maybe some of those could be merged?

Maybe some of those could be optionally compiled as a service to our
embedded friends?

/MF

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to