[iphlpapi 2/2] Fix byte ordering of Linux ports
Jason Green
jave27 at gmail.com
Tue Jul 10 23:20:29 CDT 2007
Original author: Mark Adams, TransGaming, Inc.
License: LGPL and/or MIT/X11
-------------- next part --------------
From a0b89638c6f3b2758ff920bcbd8a919f46acbe98 Mon Sep 17 00:00:00 2001
From: Jason <jason at jave02.(none)>
Date: Wed, 11 Jul 2007 00:16:37 -0400
Subject: [PATCH] Fix byte ordering of Linux ports
Original Author: Mark Adams, TransGaming, Inc.
---
dlls/iphlpapi/iphlpapi_main.c | 10 ++++++----
dlls/iphlpapi/ipstats.c | 4 ++--
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index 799f7fc..2aac18d 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -296,13 +296,15 @@ static int TcpTableSorter(const void *a,
const MIB_TCPROW* rowA = a;
const MIB_TCPROW* rowB = b;
- ret = rowA->dwLocalAddr - rowB->dwLocalAddr;
+ ret = ntohl (rowA->dwLocalAddr) - ntohl (rowB->dwLocalAddr);
if (ret == 0) {
- ret = rowA->dwLocalPort - rowB->dwLocalPort;
+ ret = ntohs ((unsigned short)rowA->dwLocalPort) -
+ ntohs ((unsigned short)rowB->dwLocalPort);
if (ret == 0) {
- ret = rowA->dwRemoteAddr - rowB->dwRemoteAddr;
+ ret = ntohl (rowA->dwRemoteAddr) - ntohl (rowB->dwRemoteAddr);
if (ret == 0)
- ret = rowA->dwRemotePort - rowB->dwRemotePort;
+ ret = ntohs ((unsigned short)rowA->dwRemotePort) -
+ ntohs ((unsigned short)rowB->dwRemotePort);
}
}
}
diff --git a/dlls/iphlpapi/ipstats.c b/dlls/iphlpapi/ipstats.c
index 874a0d5..231dd06 100644
--- a/dlls/iphlpapi/ipstats.c
+++ b/dlls/iphlpapi/ipstats.c
@@ -1316,7 +1316,7 @@ #else
if (ptr && *ptr) {
ptr++;
table->table[table->dwNumEntries].dwLocalPort =
- strtoul(ptr, &endPtr, 16);
+ htons ((unsigned short)strtoul(ptr, &endPtr, 16));
ptr = endPtr;
}
if (ptr && *ptr) {
@@ -1327,7 +1327,7 @@ #else
if (ptr && *ptr) {
ptr++;
table->table[table->dwNumEntries].dwRemotePort =
- strtoul(ptr, &endPtr, 16);
+ htons ((unsigned short)strtoul(ptr, &endPtr, 16));
ptr = endPtr;
}
if (ptr && *ptr) {
--
1.4.1
More information about the wine-patches
mailing list