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 [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
