[AGENT++] Memory corruptions with MibComplexEntry subclass get_next_request

Reetesh Ranjan reeteshr at gmail.com
Wed Aug 18 21:55:44 CEST 2010


I found a solution/workaround for this. I derived RequestList and made
community_ok() method to always return true. Thanks for the intuitive
method names.

Thanks,
Reetesh

On Thu, Aug 19, 2010 at 1:07 AM, Reetesh Ranjan <reeteshr at gmail.com> wrote:
> Frank,
>
> Thanks for the help. It solved the issue.
>
> I am now having some issue while trying to change the read/write
> community from default "public". I tried to call
> RequestList::set_read_community(), RequestList::set_write_community();
> but just this addition to the earlier code starts causing another
> memory corruption. I am creating an OctetStr object out of the string
> literal for my community string, and call the set_write_community
> method on the RequestList just after creating it. It leads to a memory
> corruption. Remove the call to set_write_community and things work
> fine again. Any inputs?
>
> Thanks,
> Reetesh
>
> On Wed, Aug 18, 2010 at 10:06 PM, Frank Fock <fock at agentpp.com> wrote:
>> You cannot assign an array of unint8 as value (and the wrong length).
>> Simply assign a valid SnmpSyntax object and all will be fine.
>>
>> Frank
>>
>> On 18.08.2010 16:23, Reetesh Ranjan wrote:
>>> I have done a simple derivation MibComplexEntry and following is the
>>> derived get_next_request function (as per suggestion by Frank in
>>> another thread from me).
>>>
>>> void SDCFsMibHandler::get_next_request(Request * request, int ind)
>>> {
>>>      uint8 lResponse[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
>>>
>>>      Vbx vb(request->get_oid(ind));
>>>
>>>      vb.set_value(lResponse, sizeof lResponse);
>>>
>>>      request->finish(ind, vb);
>>> }
>>>
>>> This code is leading to memory corruption. Dmalloc finds an error 67
>>> after function exits (but I am not sure whether because of local vars
>>> destructed or somewhere later in the flow). When I replace the local
>>> variable vb with an allocated one, then similar error comes for heap.
>>> I am trying to do a simple operation of providing a value in the
>>> get-next response.
>>>
>>> Here are the class definition and all methods implemented/derived:
>>>
>>> class SDCFsMibHandler : public MibComplexEntry
>>> {
>>> public:
>>>      // constructor
>>>      SDCFsMibHandler();
>>>
>>>      // destructor
>>>      virtual
>>>      ~SDCFsMibHandler() { }
>>>
>>>     // Needed to implement pure virtual functions (but are dummy)
>>>    virtual MibEntry * clone() { return NULL; }
>>>
>>>    virtual OidxPtr max_key(void) { return NULL; }
>>>
>>>    virtual void get_request(Request *, int) { /* no-op */ }
>>>
>>>    virtual int prepare_set_request(Request*, int&) { return SNMP_ERROR_SUCCESS; }
>>>
>>>    virtual int undo_set_request(Request*, int&) { return SNMP_ERROR_SUCCESS; }
>>>
>>>    virtual void cleanup_set_request(Request*, int&) { }
>>>
>>>    // Important derived functions
>>>    virtual void
>>>    get_next_request(Request*, int);
>>>
>>>    virtual Oidx find_succ(const Oidx&  a, Request * req=NULL);
>>>
>>>    virtual int commit_set_request(Request*, int);
>>> }
>>>
>>> SDCFsMibHandler::SDCFsMibHandler()
>>>      : MibComplexEntry("1.3.1.4.1.108.1.200.1", READWRITE)
>>> { }
>>>
>>> Oidx SDCFsMibHandler::find_succ(const Oidx&  a, Request * req)
>>> {
>>>      Oidx l = a.next_peer();
>>>      return(l);
>>> }
>>>
>>> My snmp processing code is lifted from the examples. Could you please
>>> help me with any information on this?
>>>
>>> Thanks,
>>> Reetesh
>>> _______________________________________________
>>> AGENTPP mailing list
>>> AGENTPP at agentpp.org
>>> http://lists.agentpp.org/mailman/listinfo/agentpp
>>
>> --
>> AGENT++
>> http://www.agentpp.com
>> http://www.snmp4j.com
>> http://www.mibexplorer.com
>> http://www.mibdesigner.com
>>
>> _______________________________________________
>> AGENTPP mailing list
>> AGENTPP at agentpp.org
>> http://lists.agentpp.org/mailman/listinfo/agentpp
>>
>



More information about the AGENTPP mailing list