The difference between two ULONGs may not fit in an int, causing comparison errors.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- compareIpAddrRow() and oidToIpForwardRow() should also do byte-swapping which will be done in the next patch. --- dlls/inetmib1/main.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c index 90da277375e..d19648ff792 100644 --- a/dlls/inetmib1/main.c +++ b/dlls/inetmib1/main.c @@ -772,9 +772,11 @@ static void oidToIpAddrRow(AsnObjectIdentifier *oid, void *dst)
static int __cdecl compareIpAddrRow(const void *a, const void *b) { - const MIB_IPADDRROW *key = a, *value = b; + const MIB_IPADDRROW *rowA = a, *rowB = b;
- return key->dwAddr - value->dwAddr; + return rowA->dwAddr < rowB->dwAddr ? -1 : /* avoids overflows */ + rowA->dwAddr > rowB->dwAddr ? 1 : + 0; }
static BOOL mib2IpAddrQuery(BYTE bPduType, SnmpVarBind *pVarBind, @@ -865,9 +867,11 @@ static void oidToIpForwardRow(AsnObjectIdentifier *oid, void *dst)
static int __cdecl compareIpForwardRow(const void *a, const void *b) { - const MIB_IPFORWARDROW *key = a, *value = b; + const MIB_IPFORWARDROW *rowA = a, *rowB = b;
- return key->dwForwardDest - value->dwForwardDest; + return rowA->dwForwardDest < rowB->dwForwardDest ? -1 : /* avoids overflows */ + rowA->dwForwardDest > rowB->dwForwardDest ? 1 : + 0; }
static BOOL mib2IpRouteQuery(BYTE bPduType, SnmpVarBind *pVarBind, @@ -1223,13 +1227,13 @@ static void oidToUdpRow(AsnObjectIdentifier *oid, void *dst)
static int __cdecl compareUdpRow(const void *a, const void *b) { - const MIB_UDPROW *key = a, *value = b; - int ret; + const MIB_UDPROW *rowA = a, *rowB = b; + ULONG addrA = ntohl( rowA->dwLocalAddr ); + ULONG addrB = ntohl( rowB->dwLocalAddr );
- ret = ntohl(key->dwLocalAddr) - ntohl(value->dwLocalAddr); - if (ret == 0) - ret = ntohs(key->dwLocalPort) - ntohs(value->dwLocalPort); - return ret; + return addrA < addrB ? -1 : /* avoids overflows */ + addrA > addrB ? 1 : + ntohs(rowA->dwLocalPort) - ntohs(rowB->dwLocalPort); }
static BOOL mib2UdpEntryQuery(BYTE bPduType, SnmpVarBind *pVarBind,