[AGENT++] SNMP++ 64-bit bug

Frank Fock fock at agentpp.com
Tue Jan 23 23:51:37 CET 2007


Hi Robert,

Yes, the comment is wrong. I can only note for myself's excuse,
that at the time I wrote the comment the ALPHA platform was
the only 64bit UNIX and the ntohl documentation was not very
clear.

This will be of course corrected in the next release though.

Thanks and best regards,
Frank

Robert Hancock wrote:
> I've found a problem in SNMP++ version 3.2.21a when running on a Linux 
> x86_64
> platform. In src/asn1.cpp there is this code:
> 
>     *length = ntohl(*length);
>     // ntohl even on ALPHA (DEC/COMPAQ) 64bit platforms works on 32bit int,
>     // whereas long is 64bit - therefore:
> #ifdef __osf__
>     *length >>= (8 * ((sizeof(int)) - lengthbyte));
> #else
>     *length >>= (8 * ((sizeof(long)) - lengthbyte));
> #endif
> 
> The comment is wrong, ntohl works on 32-bit values on all platforms as 
> per the
> Open Group spec, not just Alpha, so the ifdef should not be there. I 
> changed the
> code to simply:
> 
>     *length = ntohl(*length);
>     *length >>= (8 * ((sizeof(int)) - lengthbyte));
> 
> Without this fix, the agent wouldn't respond to any SNMP requests, it 
> always
> complained about "bad parse of length".
> 

-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the AGENTPP mailing list