[AGENT++] 答复: AGENTPP Digest, Vol 62, Issue 7

成俊南 chengjunnan at revenco.com
Tue Mar 31 15:49:47 CEST 2009


There is a bug in snmp++v3.2.23 on the planform(Little-Endian; int is 4;
long is 8).
asn_parse_length:
origin:
    memcpy((char *)length, (char *)data + 1, (int)lengthbyte);
    *length = ntohl(*length);
    *length >>= (8 * ((sizeof(int)) - lengthbyte));
Fixed:
    uint32_t t = 0;
    memcpy((char *)&t, (char *)data + 1, (int)lengthbyte);
    t = ntohl(t);
  	*length >>= (8 * ((sizeof(int)) - lengthbyte));

Becausal the ntohl and the >>= operation handle 64 bit long type.


-----邮件原件-----
发件人: agentpp-bounces at agentpp.org [mailto:agentpp-bounces at agentpp.org] 代
表 agentpp-request at agentpp.org
发送时间: 2009年3月31日 18:00
收件人: agentpp at agentpp.org
主题: AGENTPP Digest, Vol 62, Issue 7

Send AGENTPP mailing list submissions to
	agentpp at agentpp.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://lists.agentpp.org/mailman/listinfo/agentpp
or, via email, send a message with subject or body 'help' to
	agentpp-request at agentpp.org

You can reach the person managing the list at
	agentpp-owner at agentpp.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of AGENTPP digest..."


Today's Topics:

   1. ??: AGENTPP Digest, Vol 54, Issue 3 (???)


----------------------------------------------------------------------

Message: 1
Date: Mon, 30 Mar 2009 22:10:38 +0800
From: ??? <chengjunnan at revenco.com>
Subject: [AGENT++] ??: AGENTPP Digest, Vol 54, Issue 3
To: <agentpp at agentpp.org>
Message-ID: <007a01c9b141$4f1003d0$ed300b70$@com>
Content-Type: text/plain;	charset="gb2312"

I have tested, below list. Why the asn1 parse length failed on 64 bit
planform?

libsnmp++.so   ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV),
not stripped

Operator system : suse
Cpu info
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Xeon(R) CPU           E5440  @ 2.83GHz
stepping        : 6
cpu MHz         : 2833.478
cache size      : 6144 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 4
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm
constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr dca lahf_lm
bogomips        : 5675.47
clflush size    : 64
cache_alignment : 64
address sizes   : 38 bits physical, 48 bits virtual
power management:

int is 4 and long is 8

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This test failed.
code:
*length >>= (8 * ((sizeof(long)) - lengthbyte));

Command:
snmpget -v2c -c public 130.59.1.133:1610 1.3.6.1.4.1.31360.1.1.1.1.2.0
1.3.6.1.4.1.31360.1.1.1.1.2.0 1.3.6.1.4.1.31360.1.1.1.1.2.0
1.3.6.1.4.1.31360.1.1.1.1.2.0 1.3.6.1.4.1.31360.1.1.1.1.2.0
1.3.6.1.4.1.31360.1.1.1.1.2.0 1.3.6.1.4.1.31360.1.1.1.1.2.0
1.3.6.1.4.1.31360.1.1.1.1.2.0 1.3.6.1.4.1.31360.1.1.1.1.2.0

log:
20090330.21:53:07: 24180: (1)DEBUG  : ASN parse error (overflow of message)

20090330.21:53:07: 24180: (1)DEBUG  : ASN parse error (bad parse of version)

20090330.21:53:08: 24180: (1)DEBUG  : ASN parse error (overflow of message)

20090330.21:53:08: 24180: (1)DEBUG  : ASN parse error (bad parse of version)

20090330.21:53:09: 24180: (1)DEBUG  : ASN parse error (overflow of message)

20090330.21:53:09: 24180: (1)DEBUG  : ASN parse error (bad parse of version)

20090330.21:53:10: 24180: (1)DEBUG  : ASN parse error (overflow of message)

20090330.21:53:10: 24180: (1)DEBUG  : ASN parse error (bad parse of version)

20090330.21:53:11: 24180: (1)DEBUG  : ASN parse error (overflow of message)

20090330.21:53:11: 24180: (1)DEBUG  : ASN parse error (bad parse of version)

20090330.21:53:12: 24180: (1)DEBUG  : ASN parse error (overflow of message)

20090330.21:53:12: 24180: (1)DEBUG  : ASN parse error (bad parse of version)

20090330.21:53:13: 24180: (1)DEBUG  : ASN parse error (overflow of message)

20090330.21:53:13: 24180: (1)DEBUG  : ASN parse error (bad parse of version)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This test ok.
code:
*length >>= (8 * ((sizeof(int)) - lengthbyte));

Command:
snmpget -v2c -c public 130.59.1.133:1610 1.3.6.1.4.1.31360.1.1.1.1.2.0
1.3.6.1.4.1.31360.1.1.1.1.2.0 1.3.6.1.4.1.31360.1.1.1.1.2.0
1.3.6.1.4.1.31360.1.1.1.1.2.0 1.3.6.1.4.1.31360.1.1.1.1.2.0
1.3.6.1.4.1.31360.1.1.1.1.2.0 1.3.6.1.4.1.31360.1.1.1.1.2.0
1.3.6.1.4.1.31360.1.1.1.1.2.0 1.3.6.1.4.1.31360.1.1.1.1.2.0

log:
20090330.21:50:01: 24076: (2)EVENT  : RequestList: request received
(id)(siz)(fro)(ver)(com)(type): (22794528), (9), (130.59.1.133/32819),
(SNMPv2c), (public), (160)
20090330.21:50:01: 24076: (1)DEBUG  : TaskManager: task manager found
20090330.21:50:01: 24076: (2)DEBUG  : TaskManager: after notify
20090330.21:50:01: 24076: (2)EVENT  : Agent: starting thread execution
(pduType)(subrequests): (160), (9)
20090330.21:50:01: 24076: (2)EVENT  : Mib: process request: get request,
oid: (1), (1.3.6.1.4.1.31360.1.1.1.1.2.0), (1.3.6.1.4.1.31360.1.1.1.1.2.0),
(1.3.6.1.4.1.31360.1.1.1.1.2.0), (1.3.6.1.4.1.31360.1.1.1.1.2.0),
(1.3.6.1.4.1.31360.1.1.1.1.2.0), (1.3.6.1.4.1.31360.1.1.1.1.2.0),
(1.3.6.1.4.1.31360.1.1.1.1.2.0), (1.3.6.1.4.1.31360.1.1.1.1.2.0),
(1.3.6.1.4.1.31360.1.1.1.1.2.0)
20090330.21:50:01: 24076: (3)EVENT  : Mib: process subrequest: get request,
oid: (1), (1.3.6.1.4.1.31360.1.1.1.1.2.0)
20090330.21:50:01: 24076: (3)EVENT  : RequestList: finished subrequest
(ind)(oid)(val)(syn): (0), (1.3.6.1.4.1.31360.1.1.1.1.2.0), (0), (4)
20090330.21:50:01: 24076: (3)EVENT  : Mib: process subrequest: get request,
oid: (1), (1.3.6.1.4.1.31360.1.1.1.1.2.0)
20090330.21:50:01: 24076: (3)EVENT  : RequestList: finished subrequest
(ind)(oid)(val)(syn): (1), (1.3.6.1.4.1.31360.1.1.1.1.2.0), (0), (4)
20090330.21:50:01: 24076: (3)EVENT  : Mib: process subrequest: get request,
oid: (1), (1.3.6.1.4.1.31360.1.1.1.1.2.0)
20090330.21:50:01: 24076: (3)EVENT  : RequestList: finished subrequest
(ind)(oid)(val)(syn): (2), (1.3.6.1.4.1.31360.1.1.1.1.2.0), (0), (4)
20090330.21:50:01: 24076: (3)EVENT  : Mib: process subrequest: get request,
oid: (1), (1.3.6.1.4.1.31360.1.1.1.1.2.0)
20090330.21:50:01: 24076: (3)EVENT  : RequestList: finished subrequest
(ind)(oid)(val)(syn): (3), (1.3.6.1.4.1.31360.1.1.1.1.2.0), (0), (4)
20090330.21:50:01: 24076: (3)EVENT  : Mib: process subrequest: get request,
oid: (1), (1.3.6.1.4.1.31360.1.1.1.1.2.0)
20090330.21:50:01: 24076: (3)EVENT  : RequestList: finished subrequest
(ind)(oid)(val)(syn): (4), (1.3.6.1.4.1.31360.1.1.1.1.2.0), (0), (4)
20090330.21:50:01: 24076: (3)EVENT  : Mib: process subrequest: get request,
oid: (1), (1.3.6.1.4.1.31360.1.1.1.1.2.0)
20090330.21:50:01: 24076: (3)EVENT  : RequestList: finished subrequest
(ind)(oid)(val)(syn): (5), (1.3.6.1.4.1.31360.1.1.1.1.2.0), (0), (4)
20090330.21:50:01: 24076: (3)EVENT  : Mib: process subrequest: get request,
oid: (1), (1.3.6.1.4.1.31360.1.1.1.1.2.0)
20090330.21:50:01: 24076: (3)EVENT  : RequestList: finished subrequest
(ind)(oid)(val)(syn): (6), (1.3.6.1.4.1.31360.1.1.1.1.2.0), (0), (4)
20090330.21:50:01: 24076: (3)EVENT  : Mib: process subrequest: get request,
oid: (1), (1.3.6.1.4.1.31360.1.1.1.1.2.0)
20090330.21:50:01: 24076: (3)EVENT  : RequestList: finished subrequest
(ind)(oid)(val)(syn): (7), (1.3.6.1.4.1.31360.1.1.1.1.2.0), (0), (4)
20090330.21:50:01: 24076: (3)EVENT  : Mib: process subrequest: get request,
oid: (1), (1.3.6.1.4.1.31360.1.1.1.1.2.0)
20090330.21:50:01: 24076: (3)EVENT  : RequestList: finished subrequest
(ind)(oid)(val)(syn): (8), (1.3.6.1.4.1.31360.1.1.1.1.2.0), (0), (4)
20090330.21:50:01: 24076: (4)DEBUG  : SNMPMessage: return value for build
message: (0)
20090330.21:50:01: 24076: (1)DEBUG  : ++ SNMP++: sending to
130.59.1.133/32819:
20090330.21:50:01: 24076: (3)DEBUG  : 30 81 DA 02  01 01 04 06  70 75 62 6C
69 63 A2 81  
20090330.21:50:01: 24076: (3)DEBUG  : CC 02 04 01  5B D1 20 02  01 00 02 01
00 30 81 BD  
20090330.21:50:01: 24076: (3)DEBUG  : 30 13 06 0E  2B 06 01 04  01 81 F5 00
01 01 01 01  
20090330.21:50:01: 24076: (3)DEBUG  : 02 00 04 01  30 30 13 06  0E 2B 06 01
04 01 81 F5  
20090330.21:50:01: 24076: (3)DEBUG  : 00 01 01 01  01 02 00 04  01 30 30 13
06 0E 2B 06  
20090330.21:50:01: 24076: (3)DEBUG  : 01 04 01 81  F5 00 01 01  01 01 02 00
04 01 30 30  
20090330.21:50:01: 24076: (3)DEBUG  : 13 06 0E 2B  06 01 04 01  81 F5 00 01
01 01 01 02  
20090330.21:50:01: 24076: (3)DEBUG  : 00 04 01 30  30 13 06 0E  2B 06 01 04
01 81 F5 00  
20090330.21:50:01: 24076: (3)DEBUG  : 01 01 01 01  02 00 04 01  30 30 13 06
0E 2B 06 01  
20090330.21:50:01: 24076: (3)DEBUG  : 04 01 81 F5  00 01 01 01  01 02 00 04
01 30 30 13  
20090330.21:50:01: 24076: (3)DEBUG  : 06 0E 2B 06  01 04 01 81  F5 00 01 01
01 01 02 00  
20090330.21:50:01: 24076: (3)DEBUG  : 04 01 30 30  13 06 0E 2B  06 01 04 01
81 F5 00 01  
20090330.21:50:01: 24076: (3)DEBUG  : 01 01 01 02  00 04 01 30  30 13 06 0E
2B 06 01 04  
20090330.21:50:01: 24076: (3)DEBUG  : 01 81 F5 00  01 01 01 01  02 00 04 01
30 
20090330.21:50:01: 24076: (2)EVENT  : RequestList: request answered
(rid)(tid)(to)(err)(send)(sz): (22794528), (1), (130.59.1.133/32819), (0),
(0), (9)
20090330.21:50:01: 24076: (2)EVENT  : Agent: finished thread execution
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-----SJ<~T-<~-----
7"<~HK: agentpp-bounces at agentpp.org [mailto:agentpp-bounces at agentpp.org] 4z
1m agentpp-request at agentpp.org
7"KMJ1<d: 2008Dj7TB22HU 17:46
JU<~HK: agentpp at agentpp.org
VwLb: AGENTPP Digest, Vol 54, Issue 3

Send AGENTPP mailing list submissions to
	agentpp at agentpp.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://lists.agentpp.org/mailman/listinfo/agentpp
or, via email, send a message with subject or body 'help' to
	agentpp-request at agentpp.org

You can reach the person managing the list at
	agentpp-owner at agentpp.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of AGENTPP digest..."


Today's Topics:

   1. Re: I have a quesion about log of snmp++ (Jochen Katz)
   2. Re: snmp++v3.2.23 parse ans1 bug (Jochen Katz)


----------------------------------------------------------------------

Message: 1
Date: Mon, 21 Jul 2008 23:34:20 +0200
From: Jochen Katz <katz at agentpp.com>
Subject: Re: [AGENT++] I have a quesion about log of snmp++
To: agentpp at agentpp.org
Message-ID: <488500DC.40906 at 2008.agentpp.com>
Content-Type: text/plain; charset=windows-1252; format=flowed

Hello,

> Is there excellence the log of snmp++?
> 
> Because I use a lot of code for the log, why dont replacing current log
> system?

you can replace the default AgentLogImpl object to send all logging 
messages to your own log functions:
- Create your own AgentLog implementation (most likely as a wrapper for 
the logging API you're using) (see log.h)
- Call DefaultLog::init(new YourAgentLogImplClass()) before calling any 
other agent++/snmp++ function.

Regards,
   Jochen


------------------------------

Message: 2
Date: Mon, 21 Jul 2008 23:34:49 +0200
From: Jochen Katz <katz at agentpp.com>
Subject: Re: [AGENT++] snmp++v3.2.23 parse ans1 bug
To: agentpp at agentpp.org
Message-ID: <488500F9.0 at 2008.agentpp.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hello,

I have problems to understand your mail. For my 64 bit linux system the 
line *length >>= (8 * ((sizeof(long)) - lengthbyte)); does the right 
thing. And here int is 4 byte and long 8 byte.

Is the line above on your system wrong? Can you enable the debug 
messages and send me the error message?

Regards,
   Jochen


> I use snmp++v3.2.23.tar and agent++v3.5.29.tar.  When Snmp get 6 or over 6
> oid, agent no response.
> 
>  
> 
>  
> 
> on aix 5.3 fixed:
> 
> asn1.cpp
> 
> unsigned char * asn_parse_length( unsigned char *data, unsigned long
> *length)
> 
> *length >>= (8 * ((sizeof(long)) - lengthbyte));
> 
>  
> 
> Note: sizeof(int)=4   sizeof(long)=8
> 
>  
> 
>  
> 
> on solaris fixed:
> 
> Machine hardware:   i86pc
> 
> OS version:         5.10
> 
> Processor type:     i386
> 
> Hardware:           i86pc
> 
>  
> 
> asn1.cpp
> 
> unsigned char * asn_parse_length( unsigned char *data, unsigned long
> *length)
> 
> *length >>= (8 * ((sizeof(int)) - lengthbyte));
> 
>  
> 
> Note: sizeof(int)=4  sizeof(long)=8
> 
>  
> 
>  


------------------------------

_______________________________________________
AGENTPP mailing list
AGENTPP at agentpp.org
http://lists.agentpp.org/mailman/listinfo/agentpp


End of AGENTPP Digest, Vol 54, Issue 3
**************************************


____ KILLSJ<~02H+Mx9X RQ>-I(ChAKUb7bSJ<~ ____




------------------------------

_______________________________________________
AGENTPP mailing list
AGENTPP at agentpp.org
http://lists.agentpp.org/mailman/listinfo/agentpp


End of AGENTPP Digest, Vol 62, Issue 7
**************************************


____ KILLSJ<~02H+Mx9X RQ>-I(ChAKUb7bSJ<~ ____





More information about the AGENTPP mailing list