NetSNMP api segfaulting on OctetString with length=0
REIBENSCHUH Alfred <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <EF48306C0EFD5D4ABC8B711F4720E9599323D7@SRES1MXS1V1.res1.loc.lan.at> |
hi!
* first of all i use CentOS 4.1 Linux with the following rpms:
net-snmp-utils-5.1.2-11.EL4.6
net-snmp-libs-5.1.2-11.EL4.6
net-snmp-devel-5.1.2-11.EL4.6
net-snmp-5.1.2-11.EL4.6
* a dump of the snmp-trap i'm parsing is:
len = 198
00000000: 30 81 c3 02 01 00 04 06 70 75 62 6c 69 63 a4 81 |0.......public..|
00000010: b5 06 09 2b 06 01 04 01 02 06 03 01 40 04 a2 19 |...+........@...|
00000020: de 08 02 01 06 02 04 03 87 00 31 43 01 00 30 81 |..........1C..0.|
00000030: 95 30 11 06 0c 2b 06 01 04 01 02 06 03 01 01 02 |.0...+..........|
00000040: 00 02 01 05 30 16 06 0c 2b 06 01 04 01 02 06 03 |....0...+.......|
00000050: 01 01 03 00 04 06 3c 6e 6f 6e 65 3e 30 44 06 0c |......<none>0D..|
00000060: 2b 06 01 04 01 02 06 03 01 01 04 00 04 34 6e 65 |+............4ne|
00000070: 74 6d 6f 6e 2d 72 65 6c 61 74 65 64 20 41 70 70 |tmon-related.App|
00000080: 6c 69 63 61 74 69 6f 6e 20 64 69 73 63 6f 6e 6e |lication.disconn|
00000090: 65 63 74 69 6e 67 20 66 72 6f 6d 20 74 72 61 70 |ecting.from.trap|
000000A0: 64 2e 30 10 06 0c 2b 06 01 04 01 02 06 03 01 01 |d.0...+.........|
000000B0: 05 00 04 00 30 10 06 0c 2b 06 01 04 01 02 06 03 |....0...+.......|
000000C0: 01 01 06 00 04 00 00 00 00 00 00 00 00 00 00 00 |................|
* basically my code looks like this:
...
pdu = (netsnmp_pdu*)PR_Calloc(sizeof(netsnmp_pdu), 1);
if (snmp_pdu_parse(pdu, rcvOff, (size_t*)&rcv2Len) < 0)
{
cerr << "PDU parse error." << endl;
}
else
{
/* ... print some variables ... */
}
snmp_free_pdu(pdu);
...
* in gdb the output looks like:
...
Trap Len=198
Reading Body.
Snmp Version = 1 community ='public'
PDU parse ok.
PDU == SNMPv1 Trap.
PDU: Agent=xxx.xxx.xxx.xxx
PDU: Enterprise=.1.3.6.1.4.1.2.6.3.1
PDU: Generic=6
PDU: Specific=59179057
PDU: VarBind: Val: oid=.1.3.6.1.4.1.2.6.3.1.1.2.0
PDU: VarBind: Val: num=5
PDU: VarBind: Val: oid=.1.3.6.1.4.1.2.6.3.1.1.3.0
PDU: VarBind: Val: str='<none>' ptr=0x93739c8
PDU: VarBind: Val: oid=.1.3.6.1.4.1.2.6.3.1.1.4.0
PDU: VarBind: Val: str='netmon-related Application disconnecting from
trapd.' ptr=0x9373c50
PDU: VarBind: Val: oid=.1.3.6.1.4.1.2.6.3.1.1.5.0
PDU: VarBind: Val: strlen=0 ptr=0x9373ea0
PDU: VarBind: Val: oid=.1.3.6.1.4.1.2.6.3.1.1.6.0
PDU: VarBind: Val: strlen=0 ptr=0x93740f0
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208031552 (LWP 16151)]
0x00bc2692 in _int_free () from /lib/tls/libc.so.6
(gdb) bt full
#0 0x00bc2692 in _int_free () from /lib/tls/libc.so.6
No symbol table info available.
#1 0x00bc2eba in free () from /lib/tls/libc.so.6
No symbol table info available.
#2 0x0021f418 in snmp_free_var () from /usr/lib/libnetsnmp.so.5
No symbol table info available.
#3 0x0021f46d in snmp_free_varbind () from /usr/lib/libnetsnmp.so.5
No symbol table info available.
#4 0x0021f4b9 in snmp_free_pdu () from /usr/lib/libnetsnmp.so.5
No symbol table info available.
#5 0x08049163 in main (argc=1, argv=0xbff2cb64) at trapfwd.cpp:228
err = Variable "err" is not available.
* seams like netsnmp does not properly allocate octetstrings of length zero
?
cheers,
--
Alfred Reibenschuh