snmp_api.c/snmp_pdu_parse() not initializing pointers

This is a discussion on snmp_api.c/snmp_pdu_parse() not initializing pointers within the SNMP Coders forums, part of the Networking and Network Related category; Hi, I was looking at the snmp_pdu_parse() code because I had a crash related to using that method. The problem ...


Go Back   Usenet Forums > Networking and Network Related > SNMP Coders

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-15-2006
Gustaf Gunnarsson
 
Posts: n/a
Default snmp_api.c/snmp_pdu_parse() not initializing pointers

Hi,
I was looking at the snmp_pdu_parse() code because I had a crash related
to using that method.

The problem I ran into was that my code looked like:

netsnmp_pdu pdu;
snmp_pdu_parse(&pdu, some_data, &some_data_len)

some_data was a snmpv1 trap without any variables, because there was no
variables inside it pdu->variables never got initialized and later my
program segfaulted when I tried to do:

for (vp = pdu->variables; vp; vp = vp->next_variable)

Anyways, I now initialize all fields manually before I call
snmp_pdu_parse but is this really the way it should be?

If I was instead chosing to malloc() a netsnmp_pdu same would apply,
only I would have to initialize *all* pointers inside the netsnmp_pdu in
order to ensure that snmp_free_pdu() wount do any unexpected things.

This is quite problematic because any code written now would have to be
re-examined (or rather NetSNMP would have to be re-examined) if one were
to upgrade to a newer NetSNMP version wich *could* (I know this is not
likely, but ..) introduce new pointers inside the netsnmp_pdu structure.

I would like to change snmp_pdu_parse() so that all pointers inside the
netsnmp_pdu struct is initialized before it does anything else.

I would also like a function (I think there is none now, but I will look
some more) that would free all pointers inside a netsnmp_pdu but not
trying to free the pdu itself.

Anyways, I'll supply a patch if this seems reasonable to anyone but myself.

Oh, and this concerns NetSNMP 5.3.0.1.

Best regards,
Gustaf



_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/...et-snmp-coders
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:35 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0