Hello,
Recently some dubious code for converting a 64-bit integer to a struct
counter64 has been added to agent/mibgroup/ucd-snmp/pass.c (trunk r17731).
The following statement occurs several times: *((uint64_t *) &c64) = v64.
This statement copies a 64-bit integer to a struct counter64. Because the 32
most significant bits occur first in a struct counter64, this will work on a
big-endian CPU (e.g. PowerPC), but not on a little-endian CPU (e.g. Intel,
AMD). My proposal is to always use the code "c64.high = v64 >> 32; c64.low =
v64 & 0xffffffff;" since this code is independent of CPU endianness and
since this code does not depend on how the compiler lays out the members of
a struct counter64.
>From include/net-snmp/library/asn1.h:
...
struct counter64 {
u_long high;
u_long low;
};
...
>From agent/mibgroup/ucd-snmp/pass.c:
...
else if (!strncasecmp(buf, "integer64", 9)) {
static struct counter64 c64;
uint64_t v64 = strtoull(buf2, NULL, 10);
if (sizeof(long) > 4) { /* 64-bit machine */
c64.high = v64 >> 32;
c64.low = v64 & 0xffffffff;
}
else { /* 32-bit machine */
*((uint64_t *) &c64) = v64;
}
*var_len = sizeof(c64);
vp->type = ASN_INTEGER64;
return ((unsigned char *) &c64);
}
...
Bart.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders