I happened to get to talk to Wes about this, and his answer was basically
that these things were not meant to be mixed in this way.  I have since
changed my code to use netsnmp_register_scalar when I want to shadow a
scalar, and that works fine.

  Bill


On Wed, Nov 9, 2022 at 8:36 AM Bill Fenner <fen...@gmail.com> wrote:

> Hi,
>
> I have a MIB module that uses netsnmp_register_scalar() which realloc's
> the given root oid to have one more space in it, so that
> the netsnmp_scalar_helper_handler can use that space to store the ".0"
> instance during the handling of a request.
>
> This all works fine, until we register an instance for the same object via
> netsnmp_register_instance() - or, really, until that instance gets
> unregistered, via unregister_mib_context().  At this point, we go back to
> calling the scalar handler for that object, but, due to the duplicate
> registration, that scalar handler's registration has been duplicated via
> netsnmp_subtree_split.  Understandably, when netsnmp_subtree_split
> duplicates an OID, it doesn't add the magic extra space that the scalar
> helper needs, so after this registration and unregistration, the scalar
> helper starts stomping on memory it doesn't own.
>
> Is anyone familiar enough with this code to be able to suggest a way
> forward? If the scalar helper wants an extra oid's worth of memory in the
> rootoid pointer, it's almost like netsnmp_subtree_split needs to know that
> (e.g., a helper can provide its own implementation of snmp_duplicate_objid)?
>
> Thanks,
>   Bill
>
>
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to