Commit 9c4a1289 authored by Mark Adams's avatar Mark Adams Committed by Alexandre Julliard

iphlpapi: Fix byte ordering of Linux ports.

parent 2569635c
...@@ -296,13 +296,15 @@ static int TcpTableSorter(const void *a, const void *b) ...@@ -296,13 +296,15 @@ static int TcpTableSorter(const void *a, const void *b)
const MIB_TCPROW* rowA = a; const MIB_TCPROW* rowA = a;
const MIB_TCPROW* rowB = b; const MIB_TCPROW* rowB = b;
ret = rowA->dwLocalAddr - rowB->dwLocalAddr; ret = ntohl (rowA->dwLocalAddr) - ntohl (rowB->dwLocalAddr);
if (ret == 0) { if (ret == 0) {
ret = rowA->dwLocalPort - rowB->dwLocalPort; ret = ntohs ((unsigned short)rowA->dwLocalPort) -
ntohs ((unsigned short)rowB->dwLocalPort);
if (ret == 0) { if (ret == 0) {
ret = rowA->dwRemoteAddr - rowB->dwRemoteAddr; ret = ntohl (rowA->dwRemoteAddr) - ntohl (rowB->dwRemoteAddr);
if (ret == 0) if (ret == 0)
ret = rowA->dwRemotePort - rowB->dwRemotePort; ret = ntohs ((unsigned short)rowA->dwRemotePort) -
ntohs ((unsigned short)rowB->dwRemotePort);
} }
} }
} }
......
...@@ -1316,7 +1316,7 @@ DWORD getTcpTable(PMIB_TCPTABLE *ppTcpTable, DWORD maxEntries, HANDLE heap, ...@@ -1316,7 +1316,7 @@ DWORD getTcpTable(PMIB_TCPTABLE *ppTcpTable, DWORD maxEntries, HANDLE heap,
if (ptr && *ptr) { if (ptr && *ptr) {
ptr++; ptr++;
table->table[table->dwNumEntries].dwLocalPort = table->table[table->dwNumEntries].dwLocalPort =
strtoul(ptr, &endPtr, 16); htons ((unsigned short)strtoul(ptr, &endPtr, 16));
ptr = endPtr; ptr = endPtr;
} }
if (ptr && *ptr) { if (ptr && *ptr) {
...@@ -1327,7 +1327,7 @@ DWORD getTcpTable(PMIB_TCPTABLE *ppTcpTable, DWORD maxEntries, HANDLE heap, ...@@ -1327,7 +1327,7 @@ DWORD getTcpTable(PMIB_TCPTABLE *ppTcpTable, DWORD maxEntries, HANDLE heap,
if (ptr && *ptr) { if (ptr && *ptr) {
ptr++; ptr++;
table->table[table->dwNumEntries].dwRemotePort = table->table[table->dwNumEntries].dwRemotePort =
strtoul(ptr, &endPtr, 16); htons ((unsigned short)strtoul(ptr, &endPtr, 16));
ptr = endPtr; ptr = endPtr;
} }
if (ptr && *ptr) { if (ptr && *ptr) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment