Mark Adams : iphlpapi: Fix byte ordering of Linux ports.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Jul 12 08:32:30 CDT 2007
Module: wine
Branch: master
Commit: 9c4a1289406c46e239c4542f5cdfabd2622a97c4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9c4a1289406c46e239c4542f5cdfabd2622a97c4
Author: Mark Adams <mark at transgaming.com>
Date: Wed Jul 11 00:16:37 2007 -0400
iphlpapi: Fix byte ordering of Linux ports.
---
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 void *b)
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 7c6488c..69dd978 100644
--- a/dlls/iphlpapi/ipstats.c
+++ b/dlls/iphlpapi/ipstats.c
@@ -1316,7 +1316,7 @@ DWORD getTcpTable(PMIB_TCPTABLE *ppTcpTable, DWORD maxEntries, HANDLE heap,
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 @@ DWORD getTcpTable(PMIB_TCPTABLE *ppTcpTable, DWORD maxEntries, HANDLE heap,
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) {
More information about the wine-cvs
mailing list